how to get list of user groups from NT?

Ben Johnson ben at
Wed Mar 28 03:29:26 GMT 2001

Thanks for your help.

I have looked through the rpc_client code and thought it might be the
way to go.  I have steered clear of it so far though because 1) the code
looks so shiny and new and I need stability and 2) I need to make this
utility as small as possible, so the more code I can trim from samba the

What do you think?  Is the 2.0.7 rpc_client code stable?  I have tried
running the rpcclient from both 2.0.7 and the cvs version and have had
little success with them so far.  The 2.0.7 barely runs and the cvs HEAD
queryusergroups always complains that the filehandle is invalid.

I will try using the function directly though and maybe I'll have better
luck.  I might also try finding out how keen I am and working on tracing
though cli_samr_query_usergroups().

Thanks very much for your advice.

- Ben

On Wed, Mar 28, 2001 at 01:01:56PM +1000, Tim Potter wrote:
> Ben Johnson writes:
> > short version:  what is/are the api number(s) of the getgroups and
> > getgroupnames remote api call in smb?  I want to fetch a list of groups
> > associated with a logged in user and don't know where to look for info
> > like this.
> The call you are after is samr_query_usergroups() which
> takes a user and returns the groups the user is a member of.
> > long version:
> > Please accept my apologize in advance if this is a FAQ or is documented
> > somewhere.  I would love to rtfm if I knew where to look.  I couldn't
> > find any message in the mail archive about this.  Someone told me
> > winbind might be what I need but I haven't been able to find that
> > either.  please send me a link.
> If you want to set up winbind, you can use the -r option of the
> wbinfo command to get the groups for a particular user.  However,
> that would be a bit of effort.
> An easier way would be to use rpcclient and run the "queryusergroups"
> function.  I haven't tried this recently though.
> > My major stumbling block is the api code number.  I can't tell what it
> > is from the old source.  How exactly parameters are passed and received
> > is not all the clear either. Any other tips you care to share about this
> > task will be greatly appreciated.
> If you're really keen, you can trace through the
> cli_samr_query_usergroups() in the HEAD branch in
> libsmb/cli_samr.c for how this function is implemented.
> Tim.

More information about the samba-technical mailing list