Click here to Skip to main content
16,005,169 members
Home / Discussions / Article Writing
   

Article Writing

 
Generalresource editor Pin
14-Nov-01 9:39
suss14-Nov-01 9:39 
GeneralRe: resource editor Pin
Michael Dunn14-Nov-01 19:40
sitebuilderMichael Dunn14-Nov-01 19:40 
GeneralRe: resource editor Pin
Derek Waters21-Nov-01 13:07
Derek Waters21-Nov-01 13:07 
GeneralRe: resource editor Pin
Derek Waters21-Nov-01 13:11
Derek Waters21-Nov-01 13:11 
GeneralIE Printing Pin
14-Nov-01 7:01
suss14-Nov-01 7:01 
GeneralCheck Admin Rights of other NT account Pin
Johannes Fischer12-Nov-01 21:42
Johannes Fischer12-Nov-01 21:42 
GeneralRe: Check Admin Rights of other NT account Pin
Mats Isakson13-Nov-01 7:34
Mats Isakson13-Nov-01 7:34 
GeneralRe: Check Admin Rights of other NT account Pin
Lim Bio Liong14-Dec-01 1:13
Lim Bio Liong14-Dec-01 1:13 
Hello Johannes,

The following sample code may help you :

#include <windows.h>
#include <lmerr.h>
#include <lmaccess.h>
#include <lmapibuf.h>

void main()
{
WCHAR wszServer[] = L"\\\\server_name";
WCHAR wszUserName[] = L"user_name";
NET_API_STATUS net_api_status = 0;
GROUP_USERS_INFO_0* pgroup_users_info_0 = NULL;
USER_INFO_2* puser_info_2 = NULL;
DWORD dwentriesread = 0;
DWORD dwtotalentries = 0;

net_api_status = NetUserGetGroups
(
(LPWSTR)wszServer,
(LPWSTR)wszUserName,
(DWORD)0,
(LPBYTE *)&pgroup_users_info_0,
(DWORD)8096,
(LPDWORD)&dwentriesread,
(LPDWORD)&dwtotalentries
);

net_api_status = NetUserGetInfo
(
(LPWSTR)wszServer,
(LPWSTR)wszUserName,
(DWORD)2,
(LPBYTE *)&puser_info_2
);

if (pgroup_users_info_0)
{
NetApiBufferFree (pgroup_users_info_0);
pgroup_users_info_0 = NULL;
}

if (puser_info_2)
{
NetApiBufferFree (puser_info_2);
puser_info_2 = NULL;
}
}

The following is a summary :

1. NetUserGetInfo()
1.1 This API will return to you a USER_INFO_2 struct in which the "usri2_priv" field (type DWORD) contains one of the following values :

1.1.1 USER_PRIV_GUEST
1.1.2 USER_PRIV_USER
1.1.3 USER_PRIV_ADMIN

If USER_PRIV_ADMIN is returned, this indicates that the user has Administrator rights.

1.2 When you no longer need this USER_INFO_2 struct, call NetApiBufferFree() to free the memory for it.



2. NetUserGetGroups()
2.1. The motivation behind the use of this API is to get a list of Groups to which a user belongs and then check to see if one of these groups is "Administrators".

2.2. The NetUserGetGroups() API will return to you an array of GROUP_USERS_INFO_0 structs. Each element of the array contains a pointer to a Unicode string which is the name of a Group to which the user belongs. The last two parameters "entriesread" and "totalentries" will help to indicate to you how many elements were returned in the array.

2.3. However, I found this API a little strange in the sense that the "Administrators" group does not seem to be used.

2.4 When I specified "Administrator" as the user name, NetUserGetGroups() returns "None" as the group name.

2.5 However, you can use this API to obtain a list of Groups to which a User belongs.

2.6 Like NetUserGetInfo(), you need to delete the array of GROUP_USERS_INFO_0 structs by calling NetApiBufferFree().


Hope the above will help you, Johannes. Best of luck.

Regards,
Bio.

GeneralRe: Check Admin Rights of other NT account Pin
Johannes Fischer17-Dec-01 0:34
Johannes Fischer17-Dec-01 0:34 
GeneralRe: Check Admin Rights of other NT account Pin
Lim Bio Liong17-Dec-01 0:53
Lim Bio Liong17-Dec-01 0:53 
GeneralRe: Check Admin Rights of other NT account Pin
Lim Bio Liong18-Dec-01 0:01
Lim Bio Liong18-Dec-01 0:01 
GeneralTcp vs Unicast Udp Pin
Stephen Caldwell11-Nov-01 12:25
Stephen Caldwell11-Nov-01 12:25 
GeneralCStatic Pin
Mel Stober6-Nov-01 8:49
Mel Stober6-Nov-01 8:49 
QuestionHow do you monitor number of upload and download bit's in realtime? (in dialup, etc) Pin
6-Nov-01 0:22
suss6-Nov-01 0:22 
QuestionHow to send AT commands Pin
yskinny4-Nov-01 20:51
yskinny4-Nov-01 20:51 
GeneralModeless Dialog / Accelerators Pin
Thomas Blenkers3-Nov-01 9:18
Thomas Blenkers3-Nov-01 9:18 
GeneralSkining App in MFC Pin
MaTrIX2k22-Nov-01 9:16
MaTrIX2k22-Nov-01 9:16 
GeneralAuto Hide docking windows Pin
Bart van Haaff2-Nov-01 0:49
Bart van Haaff2-Nov-01 0:49 
GeneralRe: Auto Hide docking windows Pin
Le Ridder Noir2-Nov-01 1:44
Le Ridder Noir2-Nov-01 1:44 
GeneralRe: Auto Hide docking windows Pin
Paul A. Howes2-Nov-01 3:15
Paul A. Howes2-Nov-01 3:15 
Generalvideo conference Pin
yoavadler1-Nov-01 2:30
yoavadler1-Nov-01 2:30 
GeneralRe: video conference Pin
8-Dec-01 20:20
suss8-Dec-01 20:20 
Generalvideo conference Pin
yoavadler1-Nov-01 2:30
yoavadler1-Nov-01 2:30 
GeneralSubspace iteration C++ source codes required Pin
31-Oct-01 18:48
suss31-Oct-01 18:48 
QuestionHow can I tell programaticly what OS is running Pin
SAK31-Oct-01 9:16
SAK31-Oct-01 9:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.