我在与 LDap 交互以添加和删除用户时遇到了一些麻烦。每次我尝试执行附加的代码时,该函数要么被异常命中,要么超时。任何建议或信息都会有所帮助。
使用:System.directory.Services、linq2Ldap.Protocals、Dapper
public async Task<TaskResultOut> InsertAdGroupMemberAsync(InsertAdGroupMemberDto input)
{
TaskResultOut newReturn = null;
LdapConnection ldapConnectionV2;
NetworkCredential credential = new NetworkCredential();
try
{
ldapConnectionV2 = new LdapConnection(input.ldapserverhost);
ldapConnectionV2.Credential = credential;
ldapConnectionV2.AuthType = AuthType.Negotiate;
ldapConnectionV2.Bind(credential);
Console.WriteLine("LdapConnection is created successfully.");
var request = new AddRequest("uid=test,ou=users,dc=example,dc=com", new DirectoryAttribute[] {
new DirectoryAttribute("uid", "test"),
new DirectoryAttribute("ou", "users"),
new DirectoryAttribute("objectClass", new string[] { "top", "account", "simpleSecurityObject" })});
ldapConnectionV2.SendRequest(request);
newReturn = new TaskResultOut(true, "Ldap Update Task successful. : ");
}
catch (Exception e)
{
newReturn = new TaskResultOut(true, "Ldap Update Task Failed. : ");
}
return newReturn;
}
但没有一个对我有用。