Solved

Populate ComboBox with LDap Users

Posted on 2009-07-02
4
1,007 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
[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
  • 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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

617 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