如何从活动目录中获取电话号码 [英] How to get telephone number from active directory
本文介绍了如何从活动目录中获取电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void check()
{
// Connect to LDAP
AuthenticationTypes authTypes; // Authentication flags.
authTypes = AuthenticationTypes.Signing | AuthenticationTypes.Sealing | AuthenticationTypes.Secure;
string domainAndUsername = "xglobal" + @"\" + TextBox1.Text;
DirectoryEntry oAuthedEntry = new DirectoryEntry();
// Create new DirectorySearcher instance
DirectorySearcher search = new DirectorySearcher(oAuthedEntry);
// Set search criteria
search.Filter = "(objectCategory=user)";
//search.PropertiesToLoad.Add("displayName"); // name
//search.PropertiesToLoad.Add("physicalDeliveryOfficeName"); // location
search.PropertiesToLoad.Add("telephoneNumber"); // phone number
search.PropertiesToLoad.Add("mobile"); // mobile
//search.PropertiesToLoad.Add("mail"); // email address
//search.PropertiesToLoad.Add("msDS-UserAccountDisabled"); // account status
//search.PropertiesToLoad.Add("title"); // title
//search.PropertiesToLoad.Add("ms-DS-UserAccountAutoLocked"); // locked
search.Filter = String.Format("(SAMAccountName={0})", TextBox1.Text);
// Perform the search
SearchResultCollection results = null;
try
{
results = search.FindAll();
Response.Write(results .ToString());
我被困在这里
:confused:
I Am Stuck Here
:confused:
}
catch (Exception searchEx)
{
throw new Exception("Error obtaining users results. ", searchEx);
}
}
如果我检索了 results 集合的计数,则显示1;
但我不确定其结果是否.
If i retrive the count of the results collection , it says 1;
but i am not sure if its the result or not.
推荐答案
HI
检查链接以使用LDAP获取电话号码使用.NET类和LDAP查询来查询Active Directory [ ^ ]
只需修改代码即可获取"电话号码"而不是"名称"
HI
check the link to get Telephone Numbers using LDAP Querying Active Directory using .NET classes and LDAP queries[^]
Just modified the code to get "Telephone Number" instead of "Name"
这篇关于如何从活动目录中获取电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文