On Vista GetUserObjectInformation return 0 for lpnLengthNeeded...
-
I have a service in which i am enumarating windowstations and then all the Desktops. Then i open each desktop and get user object info to get the SID... everything is working fine on Win2000, XP but on Vista GetUserObjectInformation API returns 0 for lpnLengthNeeded which is needed to a allocated the memory Code snippet.... HDESK hDesk = OpenDesktop(lpszDesktop, DF_ALLOWOTHERACCOUNTHOOK,TRUE, DESKTOP_ENUMERATE); if(hDesk) { if(!GetUserObjectInformation(hDesk, UOI_USER_SID, NULL, 0, &dwLength)) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) AtlThrowLastWin32(); } // //If no user is associated, the value of dwLength is zero. // if(dwLength) { PSID pSid = 0; pSid = (PSID) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, dwLength); if (pSid == NULL) AtlThrow(E_OUTOFMEMORY); if (!GetUserObjectInformation(hDesk, UOI_USER_SID, pSid , dwLength, &dwLength)) AtlThrowLastWin32(); char str[250]; DWORD dw = 260; GetTextualSid(pSid,str,&dw); ///code is available in MSDN char lpName[250]; char lpDomain[250]; SID_NAME_USE SidType; if( !LookupAccountSid(0, pSid, lpName, &dw, lpDomain, &dw , &SidType ) ) { dw = GetLastError(); if( dw == ERROR_NONE_MAPPED ) wsprintf(ss,"=====SID == %s ====== NAME: NONE_MAPPED",str); else wsprintf(ss,"=====SID == %s ====== NAME: %s [%d]",str,lpName,SidType); } } }
-
I have a service in which i am enumarating windowstations and then all the Desktops. Then i open each desktop and get user object info to get the SID... everything is working fine on Win2000, XP but on Vista GetUserObjectInformation API returns 0 for lpnLengthNeeded which is needed to a allocated the memory Code snippet.... HDESK hDesk = OpenDesktop(lpszDesktop, DF_ALLOWOTHERACCOUNTHOOK,TRUE, DESKTOP_ENUMERATE); if(hDesk) { if(!GetUserObjectInformation(hDesk, UOI_USER_SID, NULL, 0, &dwLength)) { if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) AtlThrowLastWin32(); } // //If no user is associated, the value of dwLength is zero. // if(dwLength) { PSID pSid = 0; pSid = (PSID) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, dwLength); if (pSid == NULL) AtlThrow(E_OUTOFMEMORY); if (!GetUserObjectInformation(hDesk, UOI_USER_SID, pSid , dwLength, &dwLength)) AtlThrowLastWin32(); char str[250]; DWORD dw = 260; GetTextualSid(pSid,str,&dw); ///code is available in MSDN char lpName[250]; char lpDomain[250]; SID_NAME_USE SidType; if( !LookupAccountSid(0, pSid, lpName, &dw, lpDomain, &dw , &SidType ) ) { dw = GetLastError(); if( dw == ERROR_NONE_MAPPED ) wsprintf(ss,"=====SID == %s ====== NAME: NONE_MAPPED",str); else wsprintf(ss,"=====SID == %s ====== NAME: %s [%d]",str,lpName,SidType); } } }
Is DESKTOP_ENUMERATE the correct access flag you want to use? What if you use read access specifiers, maybe something like READ_CONTROL | DESKTOP_READOBJECTS.
*edit* or maybe even GENERIC_READ (DESKTOP_ENUMERATE|DESKTOP_READOBJECTS|STANDARD_RIGHTS_READ).
Mark"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")
-
Is DESKTOP_ENUMERATE the correct access flag you want to use? What if you use read access specifiers, maybe something like READ_CONTROL | DESKTOP_READOBJECTS.
*edit* or maybe even GENERIC_READ (DESKTOP_ENUMERATE|DESKTOP_READOBJECTS|STANDARD_RIGHTS_READ).
Mark"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")
-
I tried with all the combinations but its failing with all on Vista... maybe this is because in Vista MS moved all the services in Session 0 (i still have to dig into it).
Or possibly a security change?
"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")