Normal
0
21
false
false
false
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
Hello,
I'm trying
to connect to an LDAP Server (active directory) from C# using
System.DirectoryServices.Protocols in order to obtain the user mail.
Here’s a summary
of the code I’m using:
LdapConnection
_connect = new LdapConnection("serverdns.test");
_connect.Credential
= new NetworkCredential(username, password, domain);
_connect.AuthType
= AuthType.Basic;
_connect.Bind();
The Bind
operation always fails with the message: "The LDAP server is
unavailable."
I can
connect to the same server using the following code:
DirectoryEntry
entry = new
DirectoryEntry(path, username, password, AuthenticationTypes.Secure);
DirectorySearcher searcher =
new DirectorySearcher(entry);
searcher.Filter
= string.Concat("(SAMAccountName=", username, ")");
SearchResult
searchResult = searcher.FindOne();
What could
be the problem with the first piece of code?
Thanks,
Nuno