在我的 ASP.NET 应用程序中,我从 Active Directory 获取信息。我必须使用 GUID 信息获取有关用户的信息(例如:a28a6a34dsfdsf57d9e54f945a241),但我不知道如何使用过滤器进行此搜索:/
例如,如果我搜索用户姓氏:
DirectoryEntry Entry = new DirectoryEntry("LDAP://" + "Domain");
string filter = "(&(objectClass=user)(objectCategory=person)(cn=" + txtBenutzer.Text + "*))";
DirectorySearcher Searcher = new DirectorySearcher(Entry, filter);
var q = from s in Searcher.FindAll().OfType<SearchResult>()
select new
{
//GetProperty(s, "objectGUID"),
Benutzer = GetProperty(s, "sAMAccountName"),
eMail = GetProperty(s, "mail"),
Vorname = GetProperty(s, "givenName"),
Nachname = GetProperty(s, "sn"),
Telefon = GetProperty(s, "telephoneNumber"),
UserID = s.GetDirectoryEntry().NativeGuid
};
this.myListView.DataSource = q;
this.myListView.DataBind();
现在我需要一个带有 GUID 的过滤器,我可以在 AD 中找到唯一的用户。我在字符串中的此搜索的 GUID UserID = Session["UserID"].toString()
塔拉索夫