Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Getting group of a user

Posted on 1999-06-28
Medium Priority
Last Modified: 2013-11-20
Environment WinNT service pack4,
I'd like to find out to what group the currently logged on
user belongs to, I can get the name with GetUserName, but theres nothing like GetGroupName there are functions like
LookupAccountName with lots of parameters. So i do not know how
Question by:mruff
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Jedi earned 100 total points
ID: 1308156
The NetUserGetGroups function retrieves a list of global groups to which a specified user belongs.

Use netapi32.lib


Author Comment

ID: 1308157
Thanx but I still have pblms:

DWORD prefmaxlen;
DWORD entriesread;
DWORD totalentries;
GROUP_USERS_INFO_0* pusergroups;
char username[100];
int buffersize = sizeof(username);

GetUserName(username, (LPDWORD) &buffersize);
//get the users group
NET_API_STATUS result = NetUserGetGroups(NULL, (LPWSTR)username,      0,
                                                                     (unsigned char**)&pusergroups,       
                                                        &totalentries );
I always get error : NERR_UserNotFound altough i have the name of the current
logged on user (myself) in username

Expert Comment

ID: 1308158
The NETAPI functions use UNICODE-strings. Try GetUserNameW instead of GetUserName(A).

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question