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. User-rights on winnt

User-rights on winnt

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsonquestion
4 Posts 4 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.
  • T Offline
    T Offline
    tabor25
    wrote on last edited by
    #1

    Hello, exists there an api-function in c++ that i can use to determine the user-rights of the current user logged in in winnt (i need to know if the user has administrator-rights)? Best regards tabor25

    T I A 3 Replies Last reply
    0
    • T tabor25

      Hello, exists there an api-function in c++ that i can use to determine the user-rights of the current user logged in in winnt (i need to know if the user has administrator-rights)? Best regards tabor25

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      KB article Q118626 "HOWTO: Determine Whether a Thread Is Running in User Context of Local Administrator Account" has the answer. Tomasz Sowinski -- http://www.shooltz.com

      ** Putt knot yore thrust inn spel chequers. **

      1 Reply Last reply
      0
      • T tabor25

        Hello, exists there an api-function in c++ that i can use to determine the user-rights of the current user logged in in winnt (i need to know if the user has administrator-rights)? Best regards tabor25

        I Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        There are a whole bunch of functions that you can use to test for permission to perform various activities. Below is a chunk of code from an install tool I was writing. I got fed up and unsed InstallShield once I realised I was being silly reinventing the wheel, but the code pasted worked just fine! Good luck! Iain.;) if (m_bIsWinnt) { TRUSTEE Trustee; ACCESS_MASK AccessMask; ::BuildTrusteeWithName (&Trustee, "CURRENT_USER"); // Can we edit registry device entries? PSECURITY_DESCRIPTOR pSecDesc= NULL; PACL pAcl = NULL; if (::GetNamedSecurityInfo ( "MACHINE\\SYSTEM\\CurrentControlSet\\Services", SE_REGISTRY_KEY, DACL_SECURITY_INFORMATION, NULL, NULL, &pAcl, NULL, &pSecDesc) == ERROR_SUCCESS) { if (::GetEffectiveRightsFromAcl (pAcl, &Trustee, &AccessMask) == ERROR_SUCCESS) { if (AccessMask & STANDARD_RIGHTS_REQUIRED) m_bIsAdministrator = TRUE; } ::LocalFree (pSecDesc); } // Can we install to Winnt/System32/devices? char buf [MAX_PATH]; if (!GetSystemDirectory (buf, MAX_PATH)) m_bIsAdministrator = FALSE; else ::lstrcat (buf, "\\drivers"); if (m_bIsAdministrator && ::GetNamedSecurityInfo ( buf, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, &pAcl, NULL, &pSecDesc) == ERROR_SUCCESS) { if (::GetEffectiveRightsFromAcl (pAcl, &Trustee, &AccessMask) == ERROR_SUCCESS) { if (AccessMask & STANDARD_RIGHTS_REQUIRED) m_bIsAdministrator = TRUE; } ::LocalFree (pSecDesc); } else m_bIsAdministrator = FALSE; }

        1 Reply Last reply
        0
        • T tabor25

          Hello, exists there an api-function in c++ that i can use to determine the user-rights of the current user logged in in winnt (i need to know if the user has administrator-rights)? Best regards tabor25

          A Offline
          A Offline
          Andreas Saurwein
          wrote on last edited by
          #4

          Yes, there is even one simple function in the "Settlement API" as they call it. IsUserAnAdmin()[^]

          int x=1, y=5;
          x^=y^=x^=y; // whats the content of x and y now?
          ClickHereForHelp();

          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