We help IT Professionals succeed at work.

LDAP Authentication with asp.net 3.X

dajanidaoud
dajanidaoud used Ask the Experts™
on
Am trying to create a login page the authenticate the users on my Active Directory which is on another server. i am using ASP.NET 3.5 and i tryed a lot of solutions from the experts-exchange and still with no luck.

My problem seems that from the webserver i can't connect to the LDAP Server as i get the following error

Error authenticating user. The server is not operational

my LDAP Path as am using it is :

LDAP://DC=SBTH,DC=DC

any idea on a tested code that actually worked ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hey

you use serverless binding here => that means you try to connect with an LDAP path like

LDAP://DC=SBTH,DC=DC

instead of

LDAP://server_name_or_ipaddress/DC=SBTH,DC=DC

This works only if the machine where this code runs and the user credentials under which this code is run are members of the domain DC=SBTH,DC=DC... so you should give the second LDAP string a try...

Here is a god description for the LDPA Pathnames:
http://www.selfadsi.org/ldap-path.htm

Philipp

For those who suffers like me please see the attached code which worked like a charm


Dim path As String = "LDAP://Server_IP_Address"
        username = ("DomainName" & "\") + username

        Dim entry As New DirectoryEntry(path, userName, password)

        Try
            ' Bind to the native object to force authentication to happen
            ' "User authenticated" Move to the next page.
            Dim objnative As [Object] = entry.NativeObject
                          'Code after loggin in sucessfully
        Catch ex As Exception
'Code when loggin is unsucessfull
                  End Try
Dim path As String = "LDAP://Server_IP_Address"
        username = ("DomainName" & "\") + username

        Dim entry As New DirectoryEntry(path, userName, password)

        Try
            ' Bind to the native object to force authentication to happen
            ' "User authenticated" Move to the next page.
            Dim objnative As [Object] = entry.NativeObject
                          'Code after loggin in sucessfully
        Catch ex As Exception
'Code when loggin is unsucessfull
                  End Try

Open in new window

Commented:
hi i amsuffering the same pain here,,

m path As String = "LDAP://Server_IP_Address"
 would the actual server name work here?
do you added anything to web config??