• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • 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).

Thanks
0
natejacobs
Asked:
natejacobs
  • 3
  • 3
1 Solution
 
ihenryCommented:

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

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20899982.html
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_21069422.html

NOTE: use LDAP provider instead of WinNT provider.
0
 
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
0
 
ihenryCommented:
the ldap path looks incorrect, read this guide

connection string format for ldap provider
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/ldap_adspath.asp
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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?
0
 
ihenryCommented:
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.
0
 
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.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

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