Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Populate ComboBox with LDap Users

Posted on 2009-07-02
4
Medium Priority
?
1,009 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 1000 total points
ID: 24761248
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Let's recap what we learned from yesterday's Skyport Systems webinar.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

722 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