Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1014
  • Last Modified:

Populate ComboBox with LDap Users

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
kiranjjain
Asked:
kiranjjain
  • 2
1 Solution
 
DhaestCommented:
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
 
kiranjjainAuthor Commented:
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
 
DhaestCommented:
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now