Solved

Displaying Active Directory groups

Posted on 2004-09-22
6
225 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
Comment Utility

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
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Author Comment

by:natejacobs
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now