Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Worksite Trusted Login
mslearner
Hi
We have an issue encountered where
Placing our code to use logon user's token.
We encountered access denied by worksite DB.
One interesting thing is we were able to get token.
Any suggestion?
Our Code
try
{
HANDLE token;
char domain[] = "ilm.com";
::LogonUser(pLoginName, domain, pLoginPassword, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &token );
if(token == 0L)
{
//try to login to worksite.
hresult = pSession->Login( pLoginName , pLoginPassword );
if(FAILED(hresult))
{
debug->pr("normal login fail");
return NULL;
}
}
else
{
hresult = pSession->TrustedLogin2((long)token);
if(FAILED(hresult))
{
return NULL;
}
}
}
Sample Program itself
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
IManSession* WorkSiteIF::Login_To_WorkSite( char* pLoginName , char* pLoginPassword )
{
if( pLoginName == NULL || pLoginPassword == NULL )
{
return NULL;
}
HRESULT hresult;
CLSID clsid;
IClassFactory* p_classfactory;
hresult=CLSIDFromProgID(OLESTR("IManage.ManDMS"), &clsid); //retrieve CLSID of component
if(FAILED(hresult))
{
return NULL;
}
IManSessions *pSessions;
IManSession *pSession;
hresult=CoGetClassObject(clsid,CLSCTX_INPROC_SERVER,NULL,IID_IClassFactory,(LPVOID *) &p_classfactory);
//Get ManDMS object
if(FAILED(hresult))
{
return NULL;
}
p_classfactory->CreateInstance(NULL,__uuidof(IManDMS),(LPVOID*)&pIManDMS);
//Create ManDMS object
pSessions = pIManDMS->GetSessions();
if( pMyConnection == NULL )
{
return NULL;
}
int iServerLength = pMyConnection->strServer.GetLength();
char* pServerName = pMyConnection->strServer.GetBuffer(iServerLength);//Get server name
pSession = pSessions->Add( pServerName );//Add new session
try
{
HANDLE token;
char domain[] = "ilm.com";
::LogonUser(pLoginName, domain, pLoginPassword, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &token );
if(token == 0L)
{
//try to login to worksite.
hresult = pSession->Login( pLoginName , pLoginPassword );
if(FAILED(hresult))
{
debug->pr("normal login fail");
return NULL;
}
}
else
{
hresult = pSession->TrustedLogin2((long)token);
if(FAILED(hresult))
{
return NULL;
}
}
}
catch(_com_error &e)
{
return NULL;
}
pMyDataBase = pSession->GetDatabases()->ItemByIndex(1);//Set database
return pSession;
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Find more posts tagged with
Comments
There are no comments yet