我有一个程序,我想用其他用户的安全描述符,而是登陆用户的安全描述符。

解决方案 »

  1.   

    BOOL bThreadToken = FALSE;
    HANDLE hThreadToken1, hThreadToken2;//Save the current thread token
    if( OpenThreadToken(GetCurrentThread(), TOKEN_IMPERSONATE, FALSE, &hThreadToken1) )
    {
       RevertToSelf();
       bThreadToken = TRUE;
    }//Impersonate a user account
    //Insure the Sid associated with the process holds SE_TCB_NAME Privilege
    LogonUser(...);
    ImpersonateLoggedOnUser(...);
    //do user specific work here//Restore the original thread token
    if( bThreadToken )
    {
       hThreadToken2 = GetCurrentThread();
       SetThreadToken( &hThreadToken2, hThreadToken1 );
       CloseHandle( hThreadToken1 );
    }
      

  2.   

    错误号是1314
    调用LogOnUser()的时候,我的这个用户名为guest都不行。关注