-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Iamtheoneurwarnedabout
Message 5 in Discussion
Hi ,
May be the following code help you in loading all the users in a network into Combo
box.
Just paste the foillowing code in form_load event
DirectorySearcher ds = new DirectorySearcher();
ds.SearchRoot = new DirectoryEntry("");
ds.Filter =
"(|(&(objectCategory=computer)(name=*)))";//GetFilterString();
ds.PropertyNamesOnly = true;
//ds.PropertiesToLoad.Add("name");
// change the cursor to wait cursor
Cursor currentCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
// start searching
SearchResultCollection src = ds.FindAll();
try
{
foreach (SearchResult sr in src)
AddObjectToCombo(sr.GetDirectoryEntry());
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
src.Dispose();
ds.Dispose();
Cursor.Current = currentCursor;
Use one more function AddObjectToCombo and paste the following code.
public void AddObjectToCombo(DirectoryEntry de)
{
comboBox1.Items.Add(de.Name.Substring(3));
ObjectView.Update();
}
Thats it !!, it will load the all the users into drop down list.
NOte: Pls set a reference to System.DirectoryServices
Hope this may help you..... get back to me if you have any prob regarding this.
Regards,
Arshad
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]