Not able to find the property telephoneNumber using c#.Active Directory

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi All,
Im not able to get the telephoneNumber property value from the Active directory<br/>
DirectoryEntry entry = new DirectoryEntry(" LDAP://CN=Users,DC=domain,DC=com ");<br/>
DirectorySearcher Dsearch = new DirectorySearcher(entry);<br/>
string Name = "user";<br/>
//Dsearch.Filter = "(&(objectClass=user)(l=" + Name + "))";<br/>
Dsearch.Filter = "(&(objectCategory=User)(samaccountname=" + Name + "))";<br/>
// get all entries from the active directory.<br/>
// Last Name, name, initial, homepostaladdress, title, company etc..<br/>
SearchResult sResultSet = Dsearch.FindOne();
sResultSet.Properties[" telephoneNumber "][0].ToString() ;
Im able to get other properties , is it required any permissions from Active directory for getting the phone number.

REgards,
Muqeem <hr class="sig Muqeem

View the full article
 
Back
Top