473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Loop through all AD properties

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);
}
}
}
}
Nov 19 '05 #1
0 1591

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: trenchmouth | last post by:
Does anybody know how I can loop through all the properties in a class I have created? Can I use Me to refer to the properties? I'm using VB6. Many thanks.
6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
2
by: sparks | last post by:
I was going to loop thru the tables and change some properties. 10 <<<<<< prp.value --prp.name = Type False <<<<prp.value --prp.name = allow zero length 10 <<<<<< prp.value --prp.name = Type...
9
by: AP | last post by:
I personally cannot stand the Allow Design Changes property set to anything other than design view. Is there a way to loop through all forms and set this property to design view only? There always...
3
by: jcrouse | last post by:
I am trying trying to loop through some label controls and setting some properties for the labels I'm looping through. Currently I am addressing the labels one at a time with IF...Then logic, like...
15
by: James Black | last post by:
If you go to http://dante.acomp.usf.edu/HomeworkAssistant/index.php you will see my code. Type in: s = a + b and hit tab, and you will see the extra words. How do I remove these? Here is a...
10
by: fig000 | last post by:
HI, I'm new to generics. I've written a simple class to which I'm passing a generic list. I'm able to pass the list and even pass the type of the list so I can use it to traverse it. It's a...
10
by: Derek Hart | last post by:
I am going in circles trying to loop through properties on 3rd party controls. For example, I have a textbox that has its maximum length located at MyTextBox.Properties.MaxLength - instead of the...
3
by: BL3WC | last post by:
Hi, I encountered an error "Object not supporting this properties or method" while trying to set a checkbox value to 'True" in a loop. The VBA code I use is as follow: Set a value to intcount...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.