在使用C#访问活动目录时遇到问题
问题描述:
我的IS管理器为我提供了这种格式的参数,我试图使用C#来验证用户对Active目录。在使用C#访问活动目录时遇到问题
这是一个代码示例(当然不是真正的凭据)。如何使用这些参数来对一个DirectoryEntry对象,所以我可以搜索用户等
provider-url=ldap://email.acmetech.com:1111/
base-dn= DC=acmetecg,DC=com
security-authentication= simple
security-principal= CN=ldap,cn=users,DC=acmetech,DC=com
security-credentials= Ldap000
我知道这应该是简单的,但它已经有好几年我一直编程活动目录。
编辑:如何将我的PARAMS传递给目录条目对象,以便我可以查询AD中的对象?
答
使用.NET 3.5非常简单。
using(PrincipalContext pc = new PrincipalContext(ContextType.Domain, "acmetecg"))
{
// check the creds (assuming ldap is the user name, and ldap000 is the password)
bool isValid = pc.ValidateCredentials("ldap", "ldap000")
}
如果我没有问这个问题,但我该如何将我的参数传递给一个directoryEntry对象,以便我可以查询AD中的对象。 – DaGama 2011-05-03 00:45:21