C# 用C语言在ASP.NET中获取广告信息#
我是C#的ASP.NET新手 目前,我只是在摆弄一个简单的web应用程序,试图通过用户名进行搜索,并将广告的名字和姓氏显示在表格中。绝对没有成功 既然我是如此的新手,谁能告诉我怎么做,或者给我一篇关于怎么做的教程/文章 基本上这就是我的结论C# 用C语言在ASP.NET中获取广告信息#,c#,asp.net-mvc,asp.net-mvc-4,active-directory,C#,Asp.net Mvc,Asp.net Mvc 4,Active Directory,我是C#的ASP.NET新手 目前,我只是在摆弄一个简单的web应用程序,试图通过用户名进行搜索,并将广告的名字和姓氏显示在表格中。绝对没有成功 既然我是如此的新手,谁能告诉我怎么做,或者给我一篇关于怎么做的教程/文章 基本上这就是我的结论 DirectoryEntry myLDAPConnection = new DirectoryEntry("LDAP://company.com"); DirectorySearcher dSearch = new DirectorySearcher(myL
DirectoryEntry myLDAPConnection = new DirectoryEntry("LDAP://company.com");
DirectorySearcher dSearch = new DirectorySearcher(myLDAPConnection);
我知道我需要对我的dSearch对象执行一些操作来过滤返回的内容。但我不知道除此之外该怎么办
谢谢如果您使用的是.NET 3.5及更高版本,您应该查看
System.DirectoryServices.AccountManagement
(S.DS.AM)命名空间。请在此处阅读所有相关内容:
// set up domain context
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
// find a user
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");
if(user != null)
{
// do something here....
}
// find the group in question
GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "YourGroupNameHere");
// if found....
if (group != null)
{
// iterate over members
foreach (Principal p in group.GetMembers())
{
Console.WriteLine("{0}: {1}", p.StructuralObjectClass, p.DisplayName);
// do whatever you need to do to those members
}
}
}
新的S.DS.AM使得在广告中与用户和群组进行互动变得非常容易 我们使用ldap来查询active directory,这个问题看起来有一些很好的资源@约翰尼·希斯曼:将占位符(
YourGroupNameHere
)替换为您要从Active Directory检索的组名……我费了好大劲。我不知道你在向我展示如何找到一个群组,以及如何找到一个用户。谢谢您的回答。您还必须将SomeUserName
替换为您要检索的用户的实际名称-我不知道这些名称-您需要填写这些名称!:-)这比我想象的容易多了。我感谢你的帮助。一切都很完美。