Solved

Displaying Active Directory groups

Posted on 2004-09-22
6
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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