我試圖搜索我的組織Active Directory for users。根據名字,姓氏和顯示名稱在Active Directory中搜索用戶
如果名字或姓氏或 DisplayName的一個特定的字符串值相匹配,它應該返回的用戶。
我的代碼:
// create your domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
UserPrincipal qbeUser = new UserPrincipal(ctx);
qbeUser.GivenName = "Ramesh*";
// qbeUser.Surname = "Ramesh*";
// qbeUser.DisplayName= "Ramesh*";
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
// find all matches
foreach(var found in srch.FindAll())
{
//
}
的問題是,我可以只由一個過濾器來搜索。
我能夠與過濾器,但不是或。是否有任何解決方案可用?
請參閱[此問題的可能解決方案](http://stackoverflow.com/questions/3195124/ambiguous-name-resolution-anr-ma-equivalent-in-net-3-5-directoryservices-ac) - 使用'UserPrincipal'的可擴展性來訪問'anr'屬性(模糊名稱解析),它允許在多個與名稱相關的屬性中搜索 –
@marc_s:感謝您的解決方案。它工作正常。你可以發佈這個答案。所以我可以接受它? –