How I can find a User with the GUID(objectGUID) Parameter in Active Directory(如何在 Active Directory 中找到具有 GUID(objectGUID) 参数的用户)
问题描述
在我的 ASP.NET 应用程序中,我从 Active Directory 获取信息.我必须使用 GUID 信息获取有关用户的信息(例如:a28a6a34dsfdsf57d9e54f945a241),但我不知道如何正确使用过滤器进行此搜索:/
In my ASP.NET Application I get Informations from Active Directory. I must get Informations about a User with the GUID Informations (example: a28a6a34dsfdsf57d9e54f945a241) but I don't know how I can use the filter right for this search :/
例如,如果我搜索用户姓氏:
for example if I search to a User Lastname:
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()
now I need a filter with the GUID that I can find the one and only user in AD. The GUID for this Search I have in a string UserID = Session["UserID"].toString()
塔拉索夫
推荐答案
不需要搜索,知道GUID就可以直接绑定对象,例如
You don't need to search, you can bind directly to the object if you know the GUID, e.g.
var user = new DirectoryEntry("LDAP://<GUID=119d0d80-699d-4e81-8e4e-5477e22ac1b3>");
(替换为您的实际 ObjectGUID).
(replace with your actual ObjectGUID).
检查此 MSDN 条目:使用 ObjectGUID 绑定到一个对象
Check this MSDN entry: Using ObjectGUID to Bind to an Object
这篇关于如何在 Active Directory 中找到具有 GUID(objectGUID) 参数的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Active Directory 中找到具有 GUID(objectGUID) 参数的用户


基础教程推荐
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01