我正在制作一个应用程序是 asp.net 来检查一些交易报告。我想使用银行 ldap 服务器,因为银行员工只能访问该应用程序并检查这些报告。所以请指导我使用 c#(Windows 身份验证)在 asp.net 中进行 ldap 连接
问问题
4157 次
1 回答
0
如果您使用的是 .NET 3.5 及更高版本,则应查看System.DirectoryServices.AccountManagement
(S.DS.AM) 命名空间。在这里阅读所有相关信息:
基本上,您可以定义域上下文并在 AD 中轻松找到用户和/或组:
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// validate credentials
bool isValid = ctx.ValidateCredentials("myuser", "mypassword");
// find a user
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");
if(user != null)
{
// do something here....
}
新的 S.DS.AM 使得在 AD 中与用户和组一起玩变得非常容易!
此外,在 ASP.NET 中,您可能需要确保您的网站在其下运行的帐户(在 IIS 中)具有读取 AD 的权限,或者您可能需要使用以下方法之一为 AD 访问提供单独的凭据几个重载的构造函数PrincipalContext
于 2012-11-11T19:48:04.257 回答