LDAP-Authentification

  • Thread starter Thread starter Nico Koenig
  • Start date Start date
N

Nico Koenig

Hi there,

I try to make an authorisation bind to the LDAP with ASP.NET. I use the
DirectoryServices Namespace and the MSDN documented way to do it, but every
time I get an "COMException: Server is not operational". Can anyone tell me
what I have to do to avoid this???

Thanks,

Nico
 
First, make sure you have the proper LDAP path. for instance, lets say
your domain is called mycompany.local then your LDAP would be:

LDAP://DC=mycompany,DC=local

then when creating your DirectoryEntry, make sure you have the right
LDAP path, domain and username, and password like so:

DirectoryEntry entry = new
DirectoryEntry("LDAP://DC=mycompany,DC=local","mycompany.local\username","domainPassword");

If it is complaining about the server, then your problem lays somewhere
in the first couple steps of your authentication.

hope that helps!
 
what is the exception you are getting, can you post your code and then
line that is causing the problem?
 
Hi,

code:

Try
'objDirEntry = New
DirectoryEntry("LDAP://ldap.myCompany.com:636/uid=" & uid &
",ou=People,o=hp.com", "uid=" & uid & ",ou=People,o=hp.com", passwd,
AuthenticationTypes.Secure)
objDirEntry = New
DirectoryEntry("LDAP://ldap.myCompany.com:636/uid=" & uid &
",ou=People,o=myCompany.com", uid, passwd, AuthenticationTypes.Secure)
Catch ex As System.Exception
ErrorLabel.Text = ex.Message
End Try

Dim errortext As String

' get the data from the form
Dim UName As String = username.Text
Dim UDomain As String = domain.Text
Dim UserLogin As String = UDomain & ":" & UName


Dim searcher As DirectorySearcher
' execute search
searcher = New DirectorySearcher(objDirEntry)

searcher.Filter = "(ntUserDomainId=" & UserLogin & ")"

ErrorLabel.Text = searcher.FindOne().Path // <-- this throws the
Exception

Try
Dim dirEntry As New DirectoryEntry(searcher.FindOne().Path,
objDirEntry.Username, objDirEntry.Password, objDirEntry.AuthenticationType)
ErrorLabel.Text =
objDirEntry.Exists(searcher.FindOne().Path).ToString
Catch ex As System.Runtime.InteropServices.COMException
ErrorLabel.Text = ex.Message
'End Try


Exception:

System.Runtime.InteropServices.COMException: The server is not operational

Stack Trace:

COMException (0x8007203a): The server is not operational]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +514
System.DirectoryServices.DirectoryEntry.Bind() +10
System.DirectoryServices.DirectoryEntry.get_AdsObject() +10
System.DirectoryServices.DirectorySearcher.FindAll(Boolean
findMoreThanOne) +199
System.DirectoryServices.DirectorySearcher.FindOne() +31


I only get this Exception when I try to bind a user to the AD. There is no
exception if I read some data from the Directory (like username).


Thanks again

Nico
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top