LookupAccountSid ERROR_NONE_MAPPED

T

Tim Bedford

Hi,
Can anyone tell me what I'm doing wrong here? What I'm trying to do is get
the name of the user logged onto the desktop. When I step through it
everything looks fine until it gets to the LookupAccountSid call which fails
and returns error 1332 - ERROR_NONE_MAPPED.
thanks,

Tim

---------------------------------------------

BOOL IsOk;
DWORD Error;
HDESK hdesk;

Error = GetLastError();

// Get desktop handle
hdesk = OpenDesktop("default",
0,
FALSE,
READ_CONTROL | WRITE_DAC | DESKTOP_WRITEOBJECTS
| DESKTOP_READOBJECTS);

Error = GetLastError();

LPBYTE sid;
DWORD LengthNeeded;

// Get required buffer size
IsOk = GetUserObjectInformation(hdesk,
UOI_USER_SID,
NULL,
0,
&LengthNeeded);

if(!IsOk)
{
sid = new BYTE[LengthNeeded];

SetLastError(0);

Error = GetLastError();

// Get sid
IsOk = GetUserObjectInformation(hdesk,
UOI_USER_SID,
sid,
LengthNeeded,
&LengthNeeded);

Error = GetLastError();

}

IsOk = IsValidSid(sid);

char name[MAX_PATH];
DWORD NameSize = MAX_PATH;
char domain[MAX_PATH];
DWORD DomainSize = MAX_PATH;
PSID_NAME_USE peUse;

ZeroMemory(name,NameSize);
ZeroMemory(domain,DomainSize);

// Get name
IsOk = LookupAccountSid(NULL,
&sid,
name,
&NameSize,
domain,
&DomainSize,
peUse);

CloseDesktop(hdesk);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top