Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. On Vista GetUserObjectInformation return 0 for lpnLengthNeeded...

On Vista GetUserObjectInformation return 0 for lpnLengthNeeded...

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    deyadav
    wrote on last edited by
    #1

    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); } } }

    M 1 Reply Last reply
    0
    • D deyadav

      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); } } }

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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")

      D 1 Reply Last reply
      0
      • M Mark Salsbery

        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")

        D Offline
        D Offline
        deyadav
        wrote on last edited by
        #3

        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).

        M 1 Reply Last reply
        0
        • D deyadav

          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).

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Or possibly a security change?

          "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups