Solved

Populate ComboBox with LDap Users

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
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 …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

752 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