1
我试图在LDAP中搜索用户并在SharePoint中解析他的名称PeoplePicker 用户在PeoplePicker中键入用户的idsid,然后点击CheckName 代码用类型化的userid调用SearchSingleUser()。通过LDAP中的完全匹配搜索用户(SharePoint 2010人员选取器)
示例:我键入'xyz'并点击检查名称 下面的方法将搜索具有SamAccountName ='xyz'的用户的LDAP以完全匹配。如果匹配,那么发现了它应该解决idsid在peoplepicker
如果LDAP具有域\ XYZ但用户类型XYZ,它不会匹配,并不会解决
但我所看到的是,这个名字得到一半的解决。
任何线索我失踪至于寻找一个属性的确切匹配?
这是我的代码:
public static string _LDAPSearchDefSingleUser = "(&(objectClass=user)(SamAccountName={0}))";
public static SearchResultCollection SearchSingleUser(string searchPattern)
{
using (DirectoryEntry root = new DirectoryEntry(ldapPath, username, password))
{
root.AuthenticationType = AuthenticationTypes.None;
string filter = string.Format(_LDAPSearchDefSingleUser, searchPattern);
using (DirectorySearcher searcher = new DirectorySearcher(root))
{
searcher.ReferralChasing = ReferralChasingOption.All;
searcher.SearchScope = SearchScope.Subtree;
searcher.Filter = filter;
searcher.PropertiesToLoad.Add("objectclass");
searcher.PropertiesToLoad.Add("SamAccountName");
SearchResultCollection results = searcher.FindAll();
return results;
}
}
}
这对我有效。我想要完全匹配,它的工作。 – Ziggler