How to get the user group in win NT/2000/XP
-
I have a string specifying the user name in the format: "domain\username". My question is: How can I get the group to witch the user belongs to? I searched API's but couldn't find anything all I could find was "LookupAccountName" but it is not what I'm looking for. Please help if you know something. Thank's
-
I have a string specifying the user name in the format: "domain\username". My question is: How can I get the group to witch the user belongs to? I searched API's but couldn't find anything all I could find was "LookupAccountName" but it is not what I'm looking for. Please help if you know something. Thank's
LookupAccountSid()
is but one way.NetUserGetInfo()
is another.
A rich person is not the one who has the most, but the one that needs the least.
-
LookupAccountSid()
is but one way.NetUserGetInfo()
is another.
A rich person is not the one who has the most, but the one that needs the least.
This is good, but it seems to work only for local users. It doesn't work for a user on a diffrent domain for exaple if my computer name is "Station" and it belongs to the "LAN" domain and there is a user on the domain "LAN" called "globalUser" and a user on the local machine called "localUser", the function fill fail if I try to look up the user "LAN\globalUser". Even more, NetUserEnum() will not show the user called "globalUser".
-
This is good, but it seems to work only for local users. It doesn't work for a user on a diffrent domain for exaple if my computer name is "Station" and it belongs to the "LAN" domain and there is a user on the domain "LAN" called "globalUser" and a user on the local machine called "localUser", the function fill fail if I try to look up the user "LAN\globalUser". Even more, NetUserEnum() will not show the user called "globalUser".
I can use the following to get all users on my PDC:
LPUSER_INFO_0 pUserInfo = NULL,
pUserInfoTemp = NULL;
NET_API_STATUS nStatus;
DWORD dwIndex,
dwEntriesRead,
dwTotalEntries,
dwResumeHandle = 0;
CString strText;nStatus = NetUserEnum(_T("\\\\tulsant"), 0, 0, (LPBYTE *) &pUserInfo, MAX_PREFERRED_LENGTH, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle);
if (nStatus == NERR_Success || nStatus == ERROR_MORE_DATA)
{
pUserInfoTemp = pUserInfo;
if (NULL != pUserInfoTemp)
{
for (dwIndex = 0; dwIndex < dwEntriesRead; dwIndex++)
{
if (NULL == pUserInfoTemp)
break;strText = pUserInfoTemp->usri0\_name; m\_cbUserList.AddString(strText); pUserInfoTemp++; } }
}
A rich person is not the one who has the most, but the one that needs the least.
-
I can use the following to get all users on my PDC:
LPUSER_INFO_0 pUserInfo = NULL,
pUserInfoTemp = NULL;
NET_API_STATUS nStatus;
DWORD dwIndex,
dwEntriesRead,
dwTotalEntries,
dwResumeHandle = 0;
CString strText;nStatus = NetUserEnum(_T("\\\\tulsant"), 0, 0, (LPBYTE *) &pUserInfo, MAX_PREFERRED_LENGTH, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle);
if (nStatus == NERR_Success || nStatus == ERROR_MORE_DATA)
{
pUserInfoTemp = pUserInfo;
if (NULL != pUserInfoTemp)
{
for (dwIndex = 0; dwIndex < dwEntriesRead; dwIndex++)
{
if (NULL == pUserInfoTemp)
break;strText = pUserInfoTemp->usri0\_name; m\_cbUserList.AddString(strText); pUserInfoTemp++; } }
}
A rich person is not the one who has the most, but the one that needs the least.
Yes, this works fine for local users but I want to list even the users on other domains. It must be possible beacause in Win2000 when I go to "Control Panel\Users and Passwords\Add\Browse" it shows me a list of all users on my domain but NetUserEnum() only enumerates the users that are stored on my computer.
-
Yes, this works fine for local users but I want to list even the users on other domains. It must be possible beacause in Win2000 when I go to "Control Panel\Users and Passwords\Add\Browse" it shows me a list of all users on my domain but NetUserEnum() only enumerates the users that are stored on my computer.
The code snippet I provided is for iterating the userlist on the listed domain controller. If it is not working for you, something else is at play. How are you using the
NetUserEnum()
function?
A rich person is not the one who has the most, but the one that needs the least.
-
I have a string specifying the user name in the format: "domain\username". My question is: How can I get the group to witch the user belongs to? I searched API's but couldn't find anything all I could find was "LookupAccountName" but it is not what I'm looking for. Please help if you know something. Thank's
NetUserGetGroups or IADsUser::Groups