Solved

Populate ComboBox with LDap Users

Posted on 2009-07-02
4
999 Views
Last Modified: 2012-05-07
Hi,
I want to populate the Combo Box with the users in the LDAP Directory without looping thru the SearchResult of directorySearcher Search Result. how can i Achieve the same. the reason is the code takes a longer time to loop thru. if there was any code which would let me populate the Datatable which is used as datasource for my Combo Box with all the data in the search result would be helpful. i want only 3 properties of the LDAP viz Mail, SAM Account Name and Name.
Thanks in Advance

Kiran Jain
DomainName="ABC.COM";

DirectoryEntry ADSEntry = new DirectoryEntry("LDAP://" + DomainName);

            DirectorySearcher mySearcher = new DirectorySearcher(ADSEntry);

mySearcher.Filter = "(&(objectCategory=user)(name=*))";

mySearcher.PropertiesToLoad.Add("Name");

                mySearcher.PropertiesToLoad.Add("SAMAccountName");

                mySearcher.PropertiesToLoad.Add("mail");

mySearcher.Sort = new SortOption("name", SortDirection.Ascending);

SearchResultCollection src = mySearcher.FindAll();
 
 

// What should i do next......

Open in new window

0
Comment
Question by:kiranjjain
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24761030
If you want to achieve this, you can take a look at LINQ to AD
Active Directory: Get All Users using C# with Linq To Active Directory
http://www.omegacoder.com/?p=236
http://www.codeplex.com/LINQtoAD

If you are not planning to use LINQ, I don't think that there is another option than looping the results
Help getting full list of users from ldap using c#
http://forums.asp.net/t/1370476.aspx

Accessing LDAP User list using VB.NET
http://www.codeproject.com/KB/IP/LDAP_Using_VBnet.aspx
0
 
LVL 1

Author Comment

by:kiranjjain
ID: 24761176
thanks for the reply Dhaest,
i am new to programming. not very comfortable creating class etc. dont understand those much. and hence dont want to use LINQ. though using VS 2008.

just want further code to be used to populate the combo box being used.
regards,
Kiran Jain
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 250 total points
ID: 24761248
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I know all systems administrator at some time or another has had to create a script to copy file from a server share to a desktop. Well now there is an easy way to do this in Group Policy. Using Group policy preferences is not hard. The first thing …
Resolve DNS query failed errors for Exchange
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

708 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

16 Experts available now in Live!

Get 1:1 Help Now