By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,335 Members | 1,310 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,335 IT Pros & Developers. It's quick & easy.

listing usernames from Active Directory

P: n/a
Hi,
I am trying to list all usernames from active directory under the
domain 'tefter.com'

DirectoryEntry entry = new DirectoryEntry();
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = "(objectClass=user)";
//mySearcher.Filter = "(objectClass=person)";
//mySearcher.Filter = "(sAMAccountName)";

foreach(SearchResult result in mySearcher.FindAll())
{
IEnumerator ie =
result.GetDirectoryEntry().Properties["samaccountname"].GetEnumerator();
while(ie.MoveNext())
{
listBox1.Items.Add(ie.Current.ToString());
}
listBox1.Sorted = true;
}

}

this is the code i am using. but there is something wrong. I seem to be
getting some usernames but not all usernames under the domain
'tefter.com' . how do i specifiy the domain 'tefter.com' for the
search?

Regards,
NJ

May 17 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.