Function to get the local system Administrator Name
-
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
-
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
-
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
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.
-
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.
-
Thank You Naveen. The linker error has gone. Is there any other alternative function to get the local system administrator?
Taruni
-
Whats wrong with this function?
-
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 );
-
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 );
-
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