Looking for a way to query for user Group information

Hi experts,

I have been looking for a way to get all a users group information to be able to map network drives.

So far I have looked at the AD Directory.Searcher classes which seem to fail everytime I use them and haven't come across any resources on how to do this safely or easily.

If any of you have information on this please post it.

I have the username.  I just need to collect all the GROUPS...
LVL 10
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Not sure what development environment you are in but here is some VBScript that does the trick (C++ is a bit messy so I won't post that code unless specifically asked for)

Dim domain

set user = GetObject ( "WinNT://Domain/UserName" )

for each group in user.Groups
  wscript.echo group.name

Alternatively this thread may help


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Renato Montenegro RusticiIT SpecialistCommented:
You may consider using KIX32. Its perfect for login scripts.

Renato Montenegro RusticiIT SpecialistCommented:
Oh yes... i forgot. You can enumerate group membership in KIX.
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

JoesmailAuthor Commented:
Thanks for the comments.  Used the C# directory.searcher to enumerate the groups...
JoesmailAuthor Commented:
The kixstart documentation mentioned that they obtain the username/group details from the SID of the user at logon.
Do you know the WMI info to obtain this?

Also (probably a simple one).  How do you obtain the NETLOGON directory as a path when logging in.  Is this just from adding the logonserver variable to NETLOGON e.g. \\<server>\NETLOGON?  If you know of a better way would like to know.
Renato Montenegro RusticiIT SpecialistCommented:
Please, try this:

Create a batch file (loginscript.bat) and put the following:
%0\..\kix32.exe myrealscript.kix

Check this page for additional information:

Renato Montenegro RusticiIT SpecialistCommented:
So ... %0\..\ is the netlogon path
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.