[英]How I can find a User with the GUID(objectGUID) Parameter in Active Directory
在我的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中找到一個唯一的用戶。 我在字符串UserID = Session [“ UserID”]。toString()中具有此搜索的GUID
塔拉索夫
您不需要搜索,如果知道GUID,則可以直接綁定到對象,例如
var user = new DirectoryEntry("LDAP://<GUID=119d0d80-699d-4e81-8e4e-5477e22ac1b3>");
(用您實際的ObjectGUID代替)。
檢查此MSDN條目: 使用ObjectGUID綁定到對象
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.