In an aspnet-core application I want to connect to the ActiveDirectory. Therefor I want to use the following code:
LdapConnection con1 = new LdapConnection();
con1.Connect("my.company.com", 747);
con1.Bind("CN=User1,OU=Benutzerkonten,DC=my,DC=company,DC=com", "xxxxxxxxxx");
But when I call the Bind-Method I get the following Exception:
IOException: Unable to read data from the transport connection: An
existing connection was forcibly closed by the remote host..
I’ve also tried to do the add with the following line:
con1.Bind("CN=User1,OU=Benutzerkonten,DC=my,DC=company,DC=com", "xxxxxxxxxx");
The result is the same.
The LDapConnection
is from the ‘Novell.Directory.Ldap’
If I use the following code to connect to the ActiveDirectory everything just works fine:
LdapDirectoryIdentifier identifier = new LdapDirectoryIdentifier("my.company.com", 747);
NetworkCredential credential = new NetworkCredential($"COM_1\User1", "xxxxxxxxxx");
LdapConnection connection = new LdapConnection(identifier, credential, AuthType.Basic);
connection.Bind();
Unfortunately I have to use the LdapConnection
because following code depends on this class.
Am I doing something wrong at the LdapConnection or what is the reason the first code doesn’t work?