string[] properties = new string[] { "fullname" }; try { dataGridView1.ColumnCount = 3; dataGridView1.Columns[0].Name = "Name"; dataGridView1.Columns[1].Name = "Department"; dataGridView1.Columns[2].Name = "Email"; DirectoryEntry entry = new DirectoryEntry("LDAP://asdd"); DirectorySearcher mySearcher = new DirectorySearcher(entry); mySearcher.Filter = "(&(objectCategory=person)(objectClass=user))"; string[] propertiesToLoad = new string[1] { "samaccountname" }; string[] propertiesToLoad1 = new string[1] { "name" }; using (SearchResultCollection results = mySearcher.FindAll()) { foreach (SearchResult result in results) { string name = (string)result.Properties["name"][0]; string email = (string)result.Properties["mail"][0]; dataGridView1.Rows.Add(new string[] { name,email}); } } } catch { MessageBox.Show("Problem in the server"); }
foreach (string var in result.Properties.PropertyNames) { System.Diagnostics.Debug.WriteLine(string.Format("{0} : {1}", var, sr.Properties[var][0].ToString())); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)