bool COleDBConnectionProp::ConnectMSOracle(ATL::CDataSource* pDataSource,CSession* pSession)
{
	ASSERT(pDataSource);

	m_strDatabaseName = g_sDBName;
	m_strLoginName = g_sDBUser;
	m_strPassword = g_sDBPassword;
	m_strServerName = g_sDBDNS;


	CComBSTR bstrServer(m_strServerName);
	CComBSTR bstrUser(m_strLoginName);
	CComBSTR bstrPassword(m_strPassword);
	CComBSTR bstrDatabase(m_strDatabaseName);


	if (pSession && pSession->m_spOpenRowset != NULL)
		pSession->m_spOpenRowset.Release();

	
	CDBPropSet	dbinit(DBPROPSET_DBINIT);

	dbinit.AddProperty(DBPROP_AUTH_PASSWORD, bstrPassword);
	dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
	dbinit.AddProperty(DBPROP_AUTH_USERID, bstrUser);
	dbinit.AddProperty(DBPROP_INIT_DATASOURCE, bstrDatabase);
	dbinit.AddProperty(DBPROP_INIT_LCID, (long)1049);
	dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);

		
	
	if(FAILED(pDataSource->Open(_T("MSDAORA"), &dbinit)))
	{
		CString strMsg = "Cannot connect to data source";
		strMsg += "\nDatabase\t= "	+ m_strDatabaseName;
		strMsg += "\nLogin\t= "		+ m_strLoginName;
		strMsg += "\nPassword\t= "	+ m_strPassword;

		AfxMessageBox(strMsg);
		if(pDataSource)
		{
			pDataSource->Close();
		}
		goto ErrorExit;
	}
	else
	{
		if (pSession && pSession->Open(*pDataSource) != S_OK)
		{
			AfxMessageBox(_T("Couldn't create session on data source"));
			goto ErrorExit;
		}
	}
	return true;

ErrorExit:
	CloseConnection();
	return false;
}
bool COleDBConnectionProp::ConnectMSAccess(ATL::CDataSource* pDataSource,CSession* pSession)
{
	ASSERT(pDataSource);

	m_strDatabaseName = g_sDBName;
	m_strLoginName = g_sDBUser;
	m_strPassword = g_sDBPassword;
	m_strServerName = g_sDBDNS;

	CComBSTR bstrServer(m_strServerName);
	CComBSTR bstrUser(m_strLoginName);
	CComBSTR bstrPassword(m_strPassword);
	CComBSTR bstrDatabase(m_strDatabaseName);


	if (pSession && pSession->m_spOpenRowset != NULL)
		pSession->m_spOpenRowset.Release();

	
	
	CLSID clsid = {0xdee35070L,0x506b,0x11cf, 
	              {0xb1,0xaa,0x0,0xaa,0x0,0xb8,0xde,0x95}};

	
	if(FAILED(pDataSource->Open(clsid, m_strDatabaseName, NULL, NULL, DB_MODE_SHARE_EXCLUSIVE)))
	{
		CString strMsg = "Cannot connect to data source";
		strMsg += "\nDatabase\t= "	+ m_strDatabaseName;

		AfxMessageBox(strMsg);
		if(pDataSource)
		{
			pDataSource->Close();
		}
		goto ErrorExit;
	}
	else
	{
		if (pSession && pSession->Open(*pDataSource) != S_OK)
		{
			AfxMessageBox(_T("Couldn't create session on data source"));
			goto ErrorExit;
		}
	}
	return true;

ErrorExit:
	CloseConnection();
	return false;
}
bool COleDBConnectionProp::ConnectDB2(ATL::CDataSource* pDataSource,CSession* pSession)
{
	ASSERT(pDataSource);

	m_strDatabaseName = g_sDBName;
	m_strLoginName = g_sDBUser;
	m_strPassword = g_sDBPassword;
	m_strServerName = g_sDBDNS;


	CComBSTR bstrServer(m_strServerName);
	CComBSTR bstrUser(m_strLoginName);
	CComBSTR bstrPassword(m_strPassword);
	CComBSTR bstrDatabase(m_strDatabaseName);


	if (pSession && pSession->m_spOpenRowset != NULL)
		pSession->m_spOpenRowset.Release();

	
		
	if(FAILED(pDataSource->Open(_T("IBMDADB2.1"), m_strDatabaseName, m_strLoginName, m_strPassword )))
	{
		CString strMsg = "Cannot connect to data source";
		strMsg += "\nDatabase\t= "	+ m_strDatabaseName;
		strMsg += "\nLogin\t= "		+ m_strLoginName;
		strMsg += "\nPassword\t= "	+ m_strPassword;

		AfxMessageBox(strMsg);
		if(pDataSource)
		{
			pDataSource->Close();
		}
		goto ErrorExit;
	}
	else
	{
		if (pSession && pSession->Open(*pDataSource) != S_OK)
		{
			AfxMessageBox(_T("Couldn't create session on data source"));
			goto ErrorExit;
		}
	}
	return true;

ErrorExit:
	CloseConnection();
	return false;
}
CString Login( CString sUser, CString sPassword )
{
	HRESULT hr = ::CoInitialize(NULL);
	CString sOut(""); 
	try
	{
		ProcessClientServicesLib::IRpcCallHelperPtr piClientHelper(__uuidof(ProcessClientServicesLib::RpcCallHelper));
		_bstr_t bstrUser(sUser);
		_bstr_t bstrPassword(sPassword);
		CString sUpResult = (LPCTSTR)_bstr_t(piClientHelper->ClientLogin(bstrUser, bstrPassword));
		sOut = sUpResult;
	}
	catch (_com_error e)
	{
		CString strErrorMsg = e.ErrorMessage();
		ZTools::WriteZToolsFormatLog("RPC组件调用异常,%s", strErrorMsg);
		return "";
	}
	catch (COleException* e)
	{
		TCHAR szCause[255];
		CString strFormatted;
		e->GetErrorMessage(szCause, 255);
		ZTools::WriteZToolsFormatLog("PRC组件调用异常,%s", szCause);
		return "";
	}
	catch (CException* e)
	{
		TCHAR szCause[255];
		CString strFormatted;
		e->GetErrorMessage(szCause, 255);
		ZTools::WriteZToolsFormatLog("RPC组件调用异常,%s", szCause);
		return "";
	}
	if (SUCCEEDED(hr))
	{
		::CoUninitialize();
	}

	//return "{\"error\":\"0\",\"userName\":\"admin\",\"password\":\"111\",\"ticket\":\"ticket-proxy=ZzxSJrzPhvKJCElqycem\",\"realName\":\"超管\",\"roles\":\"asdf\"}";
	return sOut;
}
STDMETHODIMP CAvatarProfileObject::put_KeyGraphic(BSTR bstrKey, BSTR bstrGraphic)
{
	HRESULT hr = S_OK;
	IThing* pUser = NULL;
	IThing* pOwner = NULL;
	IAvatarProfileData* pProfileData = NULL;
	long psbits = 0;
	VARIANT_BOOL bShouldExecute = VARIANT_TRUE;
	VARIANT_BOOL bShouldRemote = VARIANT_FALSE;
	VARIANT_BOOL bShouldNotify = VARIANT_FALSE;

	GetMarshallingFlags(&bShouldExecute, &bShouldRemote, &bShouldNotify);

	if (bShouldRemote == VARIANT_TRUE)
		GetMarshallingBits(&psbits, &bShouldExecute, &bShouldRemote, &bShouldNotify);

#ifdef _DEBUG
	VWTRACE(m_pWorld, "VWPROPERTY", VWT_METHOD, "CAvatarProfileObject::put_KeyGraphic\n");
#endif

	if (bShouldExecute == VARIANT_TRUE)
	{
		if (m_pParent)
		{
			if (FAILED(m_pParent->CheckPropertySecurityExt(m_bstrPropertyName, PS_WRITE)))
			{
				VWTRACE(m_pWorld, "VWOBJECT", VWT_ERROR, "CAvatarProfileObject::put_KeyGraphic: security violation (PS_WRITE)\n");
				hr = VWOBJECT_E_PERMISSION_DENIED;
				goto ERROR_ENCOUNTERED;
			}
		}

		hr = get_Key(bstrKey, &pProfileData);
		if (FAILED(hr))
			goto ERROR_ENCOUNTERED;

		if (bShouldRemote == VARIANT_TRUE)
		{
			hr = m_pWorld->get_User(&pUser);
			if (FAILED(hr))
				goto ERROR_ENCOUNTERED;
			
			/* hr = */ pProfileData->get_Owner(&pOwner);

			// if user isn't owner of key
			if (pUser && pOwner && (pUser != pOwner))
			{
#ifdef _DEBUG
				CComBSTR bstrUser("n/a"), bstrOwner("n/a");

				/* hr = */ pUser->get_Name(&bstrUser.m_str);
				/* hr = */ pOwner->get_Name(&bstrOwner.m_str);

				VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::put_KeyGraphics: key (%s) isn't readable, user (%s), owner (%s), failed to put key value\n", CString(bstrKey), CString(bstrUser), CString(bstrOwner));
#endif
				hr = VWAVATARPROFILE_E_PERMISSIONDENIED;
				goto ERROR_ENCOUNTERED;
			}
		}

		/* hr = */ pProfileData->put_Graphic(bstrGraphic);
	}

	// remote
	if (bShouldRemote == VARIANT_TRUE)
	{
		DISPPARAMS dispparams;

		// package up args into DISPPARAMS struct
		hr = InitializeDISPPARAMS(&dispparams, 2);
		if (FAILED(hr))
			goto ERROR_ENCOUNTERED;

		dispparams.rgvarg[1].vt = VT_BSTR;
		dispparams.rgvarg[1].bstrVal = bstrKey;
		dispparams.rgvarg[0].vt = VT_BSTR;
		dispparams.rgvarg[0].bstrVal = bstrGraphic;

		hr = SendObjectPropertyCommand(psbits, DISPID_AVATARPROFILE_KEYGRAPHIC, DISPATCH_PROPERTYPUT, &dispparams);

		TerminateDISPPARAMS(VARIANT_FALSE, &dispparams);

		if (FAILED(hr))
			goto ERROR_ENCOUNTERED;
	}

	// Notify
	if (bShouldNotify == VARIANT_TRUE)
	{
		// notify client/server and world of property change
		if (m_pParent)
		{
			hr = m_pParent->NotifyObjectPropertyChanged(this, profileKeyGraphic, CComVariant(bstrKey));
			if (FAILED(hr))
				goto ERROR_ENCOUNTERED;
		}
	}
	
ERROR_ENCOUNTERED:
	SAFERELEASE(pProfileData);
	SAFERELEASE(pOwner);
	SAFERELEASE(pUser);

	return hr;
}
STDMETHODIMP CAvatarProfileObject::AddKey(BSTR bstrKey, VARIANT varKeyVal, VARIANT varStrGraphic, VARIANT varAccess, VARIANT varOwner)
{
	HRESULT hr = S_OK;
	CComVariant varTemp;
	long psbits = 0;
	IThing* pUser = NULL;
	IThing* pCaller = NULL;
	IThing* pOwner = NULL;
	IAvatarProfileData* pProfileData = NULL;
	VARIANT_BOOL bShouldExecute = VARIANT_TRUE;
	VARIANT_BOOL bShouldRemote = VARIANT_FALSE;
	VARIANT_BOOL bShouldNotify = VARIANT_FALSE;

	// REVIEW: should really create an AddKeyExt method which takes the real datatypes

	hr = VariantCopyInd(&varTemp, &varKeyVal);
	if (FAILED(hr))
		goto ERROR_ENCOUNTERED;

	if (m_pWorld)
	{
		hr = m_pWorld->ValidateProperty(varTemp);
		if (FAILED(hr))
			goto ERROR_ENCOUNTERED;
	}

	GetMarshallingFlags(&bShouldExecute, &bShouldRemote, &bShouldNotify);

	if (bShouldRemote == VARIANT_TRUE)
		GetMarshallingBits(&psbits, &bShouldExecute, &bShouldRemote, &bShouldNotify);

#ifdef _DEBUG
	VWTRACE(m_pWorld, "VWPROPERTY", VWT_METHOD, "CAvatarProfileObject::AddKey\n");
#endif

	if (bShouldExecute == VARIANT_TRUE)
	{
		VARIANT_BOOL bValid = VARIANT_FALSE;
		CComBSTR bstrGraphic;
		short sAccess = 0;

		if (m_pParent)
		{
			if (FAILED(m_pParent->CheckPropertySecurityExt(m_bstrPropertyName, PS_WRITE)))
			{
				VWTRACE(m_pWorld, "VWOBJECT", VWT_ERROR, "CAvatarProfileObject::AddKey: security violation (PS_WRITE)\n");
				hr = VWOBJECT_E_PERMISSION_DENIED;
				goto ERROR_ENCOUNTERED;
			}
		}

		if (m_pKeys == NULL)
		{
			VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::AddKey: invalid key map\n");
			hr = VWAVATARPROFILE_E_INVALIDKEYMAP;
			goto ERROR_ENCOUNTERED;
		}

		if (m_pBannedObjects == NULL)
		{
			VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::AddKey: invalid banned object list\n");
			hr = VWAVATARPROFILE_E_INVALIDBANNEDOBJECTLIST;
			goto ERROR_ENCOUNTERED;
		}

		// if user isn't avatar
		if (bShouldRemote == VARIANT_TRUE)
		{
			hr = m_pWorld->get_User(&pUser);
			if (FAILED(hr))
				goto ERROR_ENCOUNTERED;

			// we are the originator - check protocol
			if (pUser && m_pAvatar && (pUser != m_pAvatar))
			{
				long lIndex = -1;

				/* hr = */ m_pBannedObjects->Find(CComVariant(pUser), &lIndex);

				// if user is banned object, fail
				if (lIndex != -1)
				{
					VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::AddKey: user is banned object, failed to add key\n");
					hr = VWAVATARPROFILE_E_BANNEDOBJECT;
					goto ERROR_ENCOUNTERED;
				}
			}
		}

		// if key already exists, fail
		hr = m_pKeys->IsValid(bstrKey, &bValid);
		if (FAILED(hr))
			goto ERROR_ENCOUNTERED;

		if (bValid == VARIANT_TRUE)
		{
#ifdef _DEBUG
			VWTRACE(m_pWorld, "VWPROPERTY", VWT_IMPORTANT, "CAvatarProfileObject::AddKey: key (%s) already exists, failed to add key\n", CString(bstrKey));
#endif
			hr = VWAVATARPROFILE_E_KEYEXISTS;
			goto ERROR_ENCOUNTERED;
		}

		// add the property..
		pProfileData = new CComAvatarProfileData;
		if (pProfileData == NULL)
			goto ERROR_ENCOUNTERED;

		pProfileData->AddRef();

		/* hr = */ pProfileData->put_World(m_pWorld);

		// now, create the optional data items
		if (varStrGraphic.vt == VT_BSTR)
			bstrGraphic = varStrGraphic.bstrVal;
		
		if ((varAccess.vt == VT_EMPTY) || (varAccess.vt == VT_ERROR))
			sAccess = kKeyPublic;
		else
		{
			CComVariant varI2;

			::VariantChangeType(&varI2, &varAccess, 0, VT_I2);
			ASSERT(varI2.vt == VT_I2);

			sAccess = (short)varI2.iVal;
		}

		if (varOwner.vt == VT_DISPATCH)
		{
			pOwner = (IThing *)varOwner.pdispVal;
			SAFEADDREF(pOwner);
		}
		else
		{
			// if no owner passed in, set owner to be avatar
			pOwner = m_pAvatar;
			SAFEADDREF(pOwner);
		}

		// can only set the owner to the user
		if (bShouldRemote == VARIANT_TRUE)
		{
			// REVIEW: why are we resetting the owner?

			hr = m_pWorld->get_Caller(&pCaller);
			if (FAILED(hr))
				goto ERROR_ENCOUNTERED;

			// check protocol:
			// otherwise, make sure passed in owner is either user or caller
			if ((pOwner != NULL) && (pUser != NULL) && (pCaller != NULL) && (pOwner != pUser) && (pOwner != pCaller))
			{
#ifdef _DEBUG
				CComBSTR bstrUser("n/a"), bstrCaller("n/a"), bstrOwner("n/a");

				/* hr = */ pUser->get_Name(&bstrUser.m_str);
				/* hr = */ pCaller->get_Name(&bstrCaller.m_str);
				/* hr = */ pOwner->get_Name(&bstrOwner.m_str);

				VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::AddKey: invalid owner (not user or caller), user (%s), caller (%s), owner (%s)\n", 
					CString(bstrUser), CString(bstrCaller), CString(bstrOwner));
#endif

				hr = VWAVATARPROFILE_E_INVALIDOWNER;
				goto ERROR_ENCOUNTERED;
			}
		}

		/* hr = */ pProfileData->put_Value(varTemp);
		/* hr = */ pProfileData->put_Owner(pOwner);
		/* hr = */ pProfileData->put_Graphic(bstrGraphic);
		/* hr = */ pProfileData->put_Access(sAccess);

		hr = m_pKeys->put_ObjectProperty(bstrKey, pProfileData);
		if (FAILED(hr))
			goto ERROR_ENCOUNTERED;
	}

	// remote
	if (bShouldRemote == VARIANT_TRUE)
	{
		DISPPARAMS dispparams;

		// package up args into DISPPARAMS struct
		hr = InitializeDISPPARAMS(&dispparams, 5);
		if (FAILED(hr))
			goto ERROR_ENCOUNTERED;

		dispparams.rgvarg[4].vt = VT_BSTR;
		dispparams.rgvarg[4].bstrVal = bstrKey;
		dispparams.rgvarg[3] = varTemp;
		dispparams.rgvarg[2] = varStrGraphic;
		dispparams.rgvarg[1] = varAccess;
		dispparams.rgvarg[0] = varOwner;

		hr = SendObjectPropertyCommand(psbits, DISPID_AVATARPROFILE_ADDKEY, DISPATCH_METHOD, &dispparams);

		TerminateDISPPARAMS(VARIANT_FALSE, &dispparams);

		if (FAILED(hr))
			goto ERROR_ENCOUNTERED;
	}

	// Notify
	if (bShouldNotify == VARIANT_TRUE)
	{
		// notify client/server and world of property change
		if (m_pParent)
		{
			hr = m_pParent->NotifyObjectPropertyChanged(this, profileAddKey, CComVariant(bstrKey));
			if (FAILED(hr))
				goto ERROR_ENCOUNTERED;
		}
	}
	
ERROR_ENCOUNTERED:
	SAFERELEASE(pOwner);
	SAFERELEASE(pUser);
	SAFERELEASE(pCaller);
	SAFERELEASE(pProfileData);
	
	return hr;
}
BOOL CAvatarProfileObject::IsKeyReadable(IAvatarProfileData *pProfileData)
{
	static CComBSTR	kbstrFriends("Friends");
	HRESULT hr = S_OK;
	BOOL bReadable = FALSE;
	short sAccess = 0;
	IThing* pUser = NULL;
	IThing* pKeyOwner = NULL;
#ifdef _DEBUG
	CComBSTR bstrUser("n/a");
#endif

	VWTRACE(m_pWorld, "VWPROPERTY", VWT_METHOD, "CAvatarProfileObject::IsKeyReadable\n");

	if (pProfileData == NULL)
	{
		VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::IsKeyReadable: incoming argument (IAvatarProfileData*) is NULL\n");
		hr = E_INVALIDARG;
		goto ERROR_ENCOUNTERED;
	}

	hr = m_pWorld->get_User(&pUser);
	if (FAILED(hr))
	{
		VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::IsKeyReadable: failed to get user from world\n");
		hr = E_FAIL; // should never happen, but we eat the HRESULT anyway
		goto ERROR_ENCOUNTERED;
	}
	
#ifdef _DEBUG
	if (pUser)
		/* hr = */ pUser->get_Name(&bstrUser.m_str);
#endif

	/* hr = */ pProfileData->get_Access(&sAccess);
	/* hr = */ pProfileData->get_Owner(&pKeyOwner);

	if (pUser == NULL)
	{
#ifdef _DEBUG
		VWTRACE(m_pWorld, "VWPROPERTY", VWT_IMPORTANT, "CAvatarProfileObject::IsKeyReadable: no user logged into world, readable\n");
#endif
		bReadable = TRUE;
		goto ERROR_ENCOUNTERED;
	}
	else if (pUser == m_pAvatar)
	{
#ifdef _DEBUG
		VWTRACE(m_pWorld, "VWPROPERTY", VWT_IMPORTANT, "CAvatarProfileObject::IsKeyReadable: user (%s) is avatar, readable\n", CString(bstrUser));
#endif
		bReadable = TRUE;
		goto ERROR_ENCOUNTERED;
	}
	else if (pUser == pKeyOwner)
	{
#ifdef _DEBUG
		VWTRACE(m_pWorld, "VWPROPERTY", VWT_IMPORTANT, "CAvatarProfileObject::IsKeyReadable: user (%s) is owner, readable\n", CString(bstrUser));
#endif
		bReadable = TRUE;
		goto ERROR_ENCOUNTERED;
	}

	if (sAccess == kKeyPublic)
	{
		VWTRACE(m_pWorld, "VWPROPERTY", VWT_IMPORTANT, "CAvatarProfileObject::IsKeyReadable: public key, readable\n");
		bReadable = TRUE;
		goto ERROR_ENCOUNTERED;
	}
	else if (sAccess == kKeyPrivate)
	{
#ifdef _DEBUG
		VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::IsKeyReadable: user (%s) not owner or avatar, private key, not readable\n", CString(bstrUser));
#endif
		bReadable = FALSE;
		goto ERROR_ENCOUNTERED;
	}
	else if (sAccess == kKeyFriend)
	{
		CComVariant varKeyVal;
		IPropertyList *pFriendList = NULL;

		// check for friend access
		hr = get_KeyValue(kbstrFriends, &varKeyVal);
		if (SUCCEEDED(hr))
		{
			long lFriendLoc = 0L;

			pFriendList = (IPropertyList *)varKeyVal.pdispVal;
			SAFEADDREF(pFriendList);

			hr = pFriendList->Find(CComVariant(pUser), &lFriendLoc);

			if (FAILED(hr) || (lFriendLoc == -1))
			{
#ifdef _DEBUG
				VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::IsKeyReadable: user (%s) not in friends list, not readable\n", CString(bstrUser));
#endif
				bReadable = FALSE;
			}
			else
			{
#ifdef _DEBUG
				VWTRACE(m_pWorld, "VWPROPERTY", VWT_IMPORTANT, "CAvatarProfileObject::IsKeyReadable: user (%s) in friends list, readable\n", CString(bstrUser));
#endif
				bReadable = TRUE;
			}
		
			SAFERELEASE(pFriendList);
		}
		else
		{
			VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::IsKeyReadable: failed to read friends key, not readable\n");
			bReadable = FALSE;
		}
	}
	else
	{
		VWTRACE(m_pWorld, "VWPROPERTY", VWT_ERROR, "CAvatarProfileObject::IsKeyReadable: invalid access type\n");
		ASSERT(FALSE);
		hr = E_INVALIDARG;
	}

ERROR_ENCOUNTERED:
	SAFERELEASE(pKeyOwner);
	SAFERELEASE(pUser);

	return bReadable;
}
CString Login(CString strUser,CString strPswod,CString strIp,CString strbForce)
{
	HRESULT hr = ::CoInitialize(NULL);
	CString sResult(""); 
	try
	{
		ProcessClientServicesLib::IRpcCallHelperPtr piClientHelper(__uuidof(ProcessClientServicesLib::RpcCallHelper));
		_bstr_t bstrUser(strUser);
		_bstr_t bstrPassword(strPswod);
		_bstr_t bstrIp(strIp);
		_bstr_t bstrForce(strbForce);

		 sResult = (LPCTSTR)_bstr_t(piClientHelper->ERMDoLogin(bstrUser, bstrPassword,bstrIp,bstrForce));
		 if (sResult.Find("ticket-proxy=") == -1)
		 {
			 if (sResult.Compare("-2") == 0)
			 {
				 printf("系统错误,请确认服务器工作正常\n");
			 }
			 else if (sResult.Compare("-6") == 0)
			 {
				 printf("用户不存在\n");
			 }
			 else if (sResult.Compare("-7") == 0)
			 {
				 printf("密码错误\n");
			 }
			 else if (sResult.Compare("-8") == 0)
			 {
				 printf( "用户被锁定\n");
			 }
			 else if (sResult.Compare("-9") == 0)
			 {
				 printf("用户被删除\n");
			 }
			 else if (sResult.Compare("-10") == 0)
			 {
				 printf("用户被禁用\n");
			 }
			 else
			 {
				 printf("登录失败,请确认服务器工作正常\n");
			 }
		 }
		

	}
	catch (_com_error e)
	{
		CString strErrorMsg = e.ErrorMessage();
		ZTools::WriteZToolsFormatLog("RPC组件调用异常,%s", strErrorMsg);
		return "";
	}
	catch (COleException* e)
	{
		TCHAR szCause[255];
		CString strFormatted;
		e->GetErrorMessage(szCause, 255);
		ZTools::WriteZToolsFormatLog("PRC组件调用异常,%s", szCause);
		return "";
	}
	catch (CException* e)
	{
		TCHAR szCause[255];
		CString strFormatted;
		e->GetErrorMessage(szCause, 255);
		ZTools::WriteZToolsFormatLog("RPC组件调用异常,%s", szCause);
		return "";
	}
	if (SUCCEEDED(hr))
	{
		::CoUninitialize();
	}
	return sResult;
}