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