• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Displaying Active Directory groups

Does anyone know how to display the Active Directory for a given userID from a development machine?  I don't have access to the server.
If you have an example, could you modify it so that it prints from the console? System.Console.WriteLine(result).
(I'm not set up right now to run a web app).

  • 3
  • 3
1 Solution

Take a look at the memberOf attribute of user class. And these PAQs


NOTE: use LDAP provider instead of WinNT provider.
natejacobsAuthor Commented:
I'm having trouble.  Can you see any problems with my code?          

            DirectoryEntry de;
            object objGroups;

            dirEnt = new DirectoryEntry();
            dirEnt.Path = "LDAP://MYDOMAIN/USERID";
            objGroups = x.Invoke("Groups");  // Error happens here

            foreach(object ob in (IEnumerable)objGroups)
                DirectoryEntry de = new DirectoryEntry(ob);
                Console.WriteLine(de.Name );

I'm getting the exception:
System.Runtime.InteropServices.COMException (0x80072032): An invalid dn syntax has been specified
   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.get_NativeObject()
   at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
   at FindADGroups.Form1.GetGroups(String id) in c:\me\findadgroups\form1.cs:line 140
   at FindADGroups.Form1.btnGetGroups_Click(Object sender, EventArgs e) in c:\me\findadgroups\form1.cs:line 119
the ldap path looks incorrect, read this guide

connection string format for ldap provider
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

natejacobsAuthor Commented:
I played with the syntax a bit and got the message "A referral was returned from the server"

I would think that means a lack of permissions?
mm..to me the error message sounded like something is wrong with the ldap path connection string. can you post it here? and also some of your code.
natejacobsAuthor Commented:
ihenry -

Turns out another developer I work with did some work on this and has a class that does everything I need.  Apologies for pulling out in the middle of this one - thanks for your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now