Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Loop through all AD properties

Reply
Thread Tools

Loop through all AD properties

 
 
Martin
Guest
Posts: n/a
 
      04-27-2005
Hi,

Can anybody please tell me (or point me to documentation on) how to loop
through all AD properties of a user.
The code I have so far is below.
Now if I know the property name I can retrieve it, for eample to retrieve
"DisplayName"
I would just say.

de.Properties["DisplayName"].Value

so what I would like is just a display of all properties for a user,
something like this

DisplayName
Mail
Title
sAMAccountName
GivenName


it would also be nice to know what type a particular object is, for example
most properties are strings however I believe some properties are "C stucts"
cause they contain more than a single string although just to start I'd be
happy just to get the property names.

any help is appreciated

cheers

martin.

using System;
using System.DirectoryServices;

namespace TestConsole
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string query;
//query =
ConfigurationSettings.AppSettings.Get("ActiveDirec toryQueryString");
query = "LDAP://mydomain";
System.DirectoryServices.DirectoryEntry entry = new
System.DirectoryServices.DirectoryEntry(query);
System.DirectoryServices.DirectorySearcher mySearcher = new
System.DirectoryServices.DirectorySearcher(entry);

try
{
foreach(System.DirectoryServices.SearchResult resEnt in
mySearcher.FindAll())
{
System.DirectoryServices.DirectoryEntry de=resEnt.GetDirectoryEntry();

//would like to get all properties (property name) here perhaps in a
foreach loop
foreach (DirectoryEntry child in de.Children)
{
Console.WriteLine(child.Name);
}

}

}
catch (Exception ex)
{
Console.WriteLine("ERROR ERROR ERROR " + ex.Message);
}
}
}
}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Re: How to loop through a list while inside the loop, the list size may be decreased? Roedy Green Java 3 09-13-2008 01:51 AM
Not able to copy all properties using properties.putAll() method. Sonal Java 3 12-07-2007 03:08 AM
Using class properties through all asp.net pages in 1 project Nick Wouters ASP .Net 4 10-12-2005 01:31 PM
Loop through all dataadapters Vik ASP .Net 2 07-17-2003 02:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57