Solved

Displaying Active Directory groups

Posted on 2004-09-22
6
240 Views
Last Modified: 2007-12-19
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
Comment
Question by:natejacobs
  • 3
  • 3
6 Comments
 
LVL 20

Expert Comment

by:ihenry
ID: 12125736

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
 
LVL 3

Author Comment

by:natejacobs
ID: 12126952
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
 
LVL 20

Expert Comment

by:ihenry
ID: 12127035
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 3

Author Comment

by:natejacobs
ID: 12127187
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
 
LVL 20

Accepted Solution

by:
ihenry earned 350 total points
ID: 12130927
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
 
LVL 3

Author Comment

by:natejacobs
ID: 12132739
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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