//A.R. Jeder = S-1-1-0
if Ansiuppercase(lpszAccountName)='
JEDER'
then
Begin
pUserSID := PAnsichar('
'#1#1#0#0#0#0#0#1#0#0#0#0);
cbUserSID := 12;
end
Else
Begin
//
// STEP 1: Get SID of the account name specified.
//
fAPISuccess := LookupAccountName(
nil, lpszAccountName,
pUserSID, cbUserSID, szDomain, cbDomain, snuType);
// API should have failed with insufficient buffer.
if (
Not fAPISuccess)
AND (GetLastError() <> ERROR_INSUFFICIENT_BUFFER)
then
raise Exception.Create('
LookupAccountName Error=' + IntToStr(GetLastError()));
pUserSID := myheapalloc(cbUserSID);
if pUserSID =
nil then
raise Exception.Create('
myheapalloc Error=' + IntToStr(GetLastError()));
szDomain := PChar(myheapalloc(cbDomain * sizeof(PChar)));
if szDomain =
nil then
raise Exception.Create('
myheapalloc Error=' + IntToStr(GetLastError()));
fAPISuccess := LookupAccountName(
nil, lpszAccountName,
pUserSID, cbUserSID, szDomain, cbDomain, snuType);
if Not fAPISuccess
then
raise Exception.Create('
LookupAccountName Error=' + IntToStr(GetLastError()));
end;