Article View: borland.public.cppbuilder.nativeapi
Article #7680Re: user impersonation
From: Remy Lebeau (TeamB)
Date: Fri, 07 Jan 2005 18:03
Date: Fri, 07 Jan 2005 18:03
34 lines
2114 bytes
2114 bytes
"Costin" <decbis@yahoo.com> wrote in message
news:41de7bc9@newsgroups.borland.com...
> Here is a typical code sequence:
For future reference, please clean up your code before you post it. You
posted a big jumble of code that was clumped together without line breaks,
spaces, tabs, etc. Very hard to read.
> if( !ImpersonateLoggedOnUser(token) )
> {
> token=NULL;
> return false;
> }
You did not close the token before returning. Your code is still logged in
to the user account.
> if( token )
> CloseHandle(token);
You never called RevertToSelf(), so the code is still impersonating the user
even though you closed the token.
Also, you did not verify that the thread had the SE_TCB_NAME privilege
before calling LogonUser(). Use OpenThreadToken() to get the thread's own
access token, then use GetTokenInformation() to see if the thread already
has the SE_TCB_NAME privilege. If not, then call AdjustTokenProvileges() to
give the thread token the SE_TCB_NAME privilege. Without SE_TCB_NAME,
LogonUser() will fail.
Gambit
Technical Details
Message-ID:
<41dece9a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!newsfeed3.dallas1.level3.net!news.level3.com!newsfeeds.sol.net!newspump.sol.net!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<41ddbfd3@newsgroups.borland.com> <41ddc480$2@newsgroups.borland.com> <41de7bc9@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c4e8c83fb5b37558 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <41ddbfd3@newsgroups.borland.com> <41ddc480$2@newsgroups.borland.com> <41de7bc9@newsgroups.borland.com> Subject: Re: user impersonation Date: Fri, 7 Jan 2005 10:03:41 -0800 Lines: 36 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <41dece9a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1105120922 68.69.17.41 (7 Jan 2005 10:02:02 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!newsfeed3.dallas1.level3.net!news.level3.com!newsfeeds.sol.net!newspump.sol.net!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail