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. Function to get the local system Administrator Name

Function to get the local system Administrator Name

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studiohelpquestion
9 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
    Taruni
    wrote on last edited by
    #1

    Hi I need to get the name of the local system Administrator (System is in the domain). As that name however appears in the ControlPanel->"UserAccounts" list or ControlPanel->AdministrativeTools->ComputerManagement->LocalUser and Groups->Groups and clicking on "Administrators" Group, I am trying to list out all the users under "Administrators" Group and for this purpose I am using NetLocalGroupGetMembers() and including lmaccess.h file. But I am getting the linker error "error LNK2001: unresolved external symbol _NetLocalGroupGetMembers@32". Doesn't this header file "lmaccess.h" come with Visual Studio? Using ADSI, I can get the members of an "Administrators" group (local system) , however, that list doesn't include the name of the the local system administrator , who is a member in the domain. Is there anyother alternative mechanism/function to get the local system Administrator Name? Thanks in Advance.

    Taruni

    N enhzflepE 2 Replies Last reply
    0
    • T Taruni

      Hi I need to get the name of the local system Administrator (System is in the domain). As that name however appears in the ControlPanel->"UserAccounts" list or ControlPanel->AdministrativeTools->ComputerManagement->LocalUser and Groups->Groups and clicking on "Administrators" Group, I am trying to list out all the users under "Administrators" Group and for this purpose I am using NetLocalGroupGetMembers() and including lmaccess.h file. But I am getting the linker error "error LNK2001: unresolved external symbol _NetLocalGroupGetMembers@32". Doesn't this header file "lmaccess.h" come with Visual Studio? Using ADSI, I can get the members of an "Administrators" group (local system) , however, that list doesn't include the name of the the local system administrator , who is a member in the domain. Is there anyother alternative mechanism/function to get the local system Administrator Name? Thanks in Advance.

      Taruni

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      You need to add Netapi32.lib to your project. If you are using VS6, take project settings->Link Tab and in that you can find a edit box "Object/library modules". Enter Netapi32.lib in it.

      nave [OpenedFileFinder] [My Blog]

      T 1 Reply Last reply
      0
      • T Taruni

        Hi I need to get the name of the local system Administrator (System is in the domain). As that name however appears in the ControlPanel->"UserAccounts" list or ControlPanel->AdministrativeTools->ComputerManagement->LocalUser and Groups->Groups and clicking on "Administrators" Group, I am trying to list out all the users under "Administrators" Group and for this purpose I am using NetLocalGroupGetMembers() and including lmaccess.h file. But I am getting the linker error "error LNK2001: unresolved external symbol _NetLocalGroupGetMembers@32". Doesn't this header file "lmaccess.h" come with Visual Studio? Using ADSI, I can get the members of an "Administrators" group (local system) , however, that list doesn't include the name of the the local system administrator , who is a member in the domain. Is there anyother alternative mechanism/function to get the local system Administrator Name? Thanks in Advance.

        Taruni

        enhzflepE Offline
        enhzflepE Offline
        enhzflep
        wrote on last edited by
        #3

        Taruni wrote:

        I am getting the linker error "error LNK2001: unresolved external symbol _NetLocalGroupGetMembers@32". Doesn't this header file "lmaccess.h" come with Visual Studio?

        Yup sure does, that's why it's a linker error and not a compile error that you're getting. You'll have to link the netapi32.lib to get access to the function. :-\ Yeah, what Naveen said.

        1 Reply Last reply
        0
        • N Naveen

          You need to add Netapi32.lib to your project. If you are using VS6, take project settings->Link Tab and in that you can find a edit box "Object/library modules". Enter Netapi32.lib in it.

          nave [OpenedFileFinder] [My Blog]

          T Offline
          T Offline
          Taruni
          wrote on last edited by
          #4

          Thank You Naveen. The linker error has gone. Is there any other alternative function to get the local system administrator?

          Taruni

          N 1 Reply Last reply
          0
          • T Taruni

            Thank You Naveen. The linker error has gone. Is there any other alternative function to get the local system administrator?

            Taruni

            N Offline
            N Offline
            Naveen
            wrote on last edited by
            #5

            Whats wrong with this function?

            nave [OpenedFileFinder] [My Blog]

            T 1 Reply Last reply
            0
            • N Naveen

              Whats wrong with this function?

              nave [OpenedFileFinder] [My Blog]

              T Offline
              T Offline
              Taruni
              wrote on last edited by
              #6

              I am unable to understand as how to enumerate the users list.

              Taruni

              N D 2 Replies Last reply
              0
              • T Taruni

                I am unable to understand as how to enumerate the users list.

                Taruni

                N Offline
                N Offline
                Naveen
                wrote on last edited by
                #7

                sample code:

                LPLOCALGROUP_MEMBERS_INFO_1 pstMembersInfo = 0;
                DWORD entriesread = 0;
                DWORD totalentries = 0;

                if( 0 != NetLocalGroupGetMembers( NULL, \_T("Administrators"), 1, (LPBYTE\*)&pstMembersInfo, 
                                         MAX\_PREFERRED\_LENGTH, &entriesread, &totalentries, 0 ))
                {
                    AfxMessageBox( \_T("NetLocalGroupGetMembers failed !"));
                    return ;
                }
                
                for( DWORD dwIdx =0; dwIdx  < entriesread; dwIdx ++ )
                {
                    AfxMessageBox( pstMembersInfo\[dwIdx\].lgrmi1\_name );
                }
                NetApiBufferFree( pstMembersInfo );
                

                nave [OpenedFileFinder] [My Blog]

                T 1 Reply Last reply
                0
                • N Naveen

                  sample code:

                  LPLOCALGROUP_MEMBERS_INFO_1 pstMembersInfo = 0;
                  DWORD entriesread = 0;
                  DWORD totalentries = 0;

                  if( 0 != NetLocalGroupGetMembers( NULL, \_T("Administrators"), 1, (LPBYTE\*)&pstMembersInfo, 
                                           MAX\_PREFERRED\_LENGTH, &entriesread, &totalentries, 0 ))
                  {
                      AfxMessageBox( \_T("NetLocalGroupGetMembers failed !"));
                      return ;
                  }
                  
                  for( DWORD dwIdx =0; dwIdx  < entriesread; dwIdx ++ )
                  {
                      AfxMessageBox( pstMembersInfo\[dwIdx\].lgrmi1\_name );
                  }
                  NetApiBufferFree( pstMembersInfo );
                  

                  nave [OpenedFileFinder] [My Blog]

                  T Offline
                  T Offline
                  Taruni
                  wrote on last edited by
                  #8

                  Thank you Naveen for the great help.

                  Taruni

                  1 Reply Last reply
                  0
                  • T Taruni

                    I am unable to understand as how to enumerate the users list.

                    Taruni

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    What does that have to do with using another function? Regardless of how the list is obtained, wouldn't you still need to iterate through it?

                    "Love people and use things, not love things and use people." - Unknown

                    "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                    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