Article View: borland.public.cppbuilder.nativeapi
Article #12835Re: LookupAccountName()
From: Remy Lebeau (TeamB)
Date: Sat, 15 Nov 2003 03:05
Date: Sat, 15 Nov 2003 03:05
59 lines
2454 bytes
2454 bytes
"Mike Collins" <mikec@kr8.co.uk> wrote in message
news:3fb5891d@newsgroups.borland.com...
> Does anyone have any robust code examples of
> LookupAccountName() api?
For example (untested):
PSID GetSIDFromUsername(const AnsiString &Username)
{
PSID pSid = NULL;
DWORD dwSidSize = 0;
TCHAR szDomain[1024] = {0};
DWORD dwDomainSize = 1024;
SID_NAME_USE AccountType;
LookupAccountName(NULL, Username.c_str(), NULL, &dwSidSize,
szDomain, &dwDomainSize, &AccountType);
if( dwSidSize )
{
pSid = (PSID) GlobalAlloc(GPTR, dwSidSize);
if( pSid )
{
if( LookupAccountName(NULL, Username.c_str(), pSid,
&dwSidSize, szDomain, &dwDomainSize, &AccountType) )
return pSid;
GlobalFree(pSid);
}
}
return NULL;
}
PSID pSid = GetSIDFromUsername("joesme");
if( pSid )
{
// use pSid as needed
GlobalFree(pSid);
}
> I keep getting the error "No mapping between account names
> and security IDs was done" returned by LookupAccountName().
The only time I have heard of that happening is when you are trying to
resolve a username that belongs to a different domain than the server that
is specified in the lpSystemName parameter.
> I can post my function code if necessary...
That would be preferred.
Gambit
Technical Details
Message-ID:
<3fb5970d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!opentransit.net!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fb5891d@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5d9b0a085dbf01d2 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-11-14 19:07:27 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3fb5891d@newsgroups.borland.com> Subject: Re: LookupAccountName() Date: Fri, 14 Nov 2003 19:05:08 -0800 Lines: 61 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.137.149 Message-ID: <3fb5970d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1068865293 67.22.137.149 (14 Nov 2003 19:01:33 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!opentransit.net!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail