softsolvers
2004-12-14 11:31:01 UTC
hello to all experts,
i am new to LDAP and accessing Active Directory from ASP.NET .
i am getting an error
<Error authenticating user. A referral was returned from the server>
as soon as my debugger executes line
Dim search As DirectorySearcher = New DirectorySearcher(entry)
complete code is given belo
-------------------------------------------------------------------------------------------
Dim _path As String = "LDAP://mercury/cn=users,dc=local" 'Path to your
LDAP directory server
Dim domain = TextBox1.Text 'contains--- XXX , our
domain
Dim username = TextBox2.Text 'contains--- sama ,
existing user
Dim pwd = TextBox3.Text 'contains ---abc ,
sama's pwd
Dim domainAndUsername As String = domain & "\" & username
Dim entry As DirectoryEntry = New DirectoryEntry(_path,
domainAndUsername, pwd)
Try
Dim search As DirectorySearcher = New DirectorySearcher(entry)
search.Filter = "(SAMAccountName=" & username & ")"
search.PropertiesToLoad.Add("cn")
Dim result As SearchResult = search.FindOne()
If (result Is Nothing) Then
Throw New Exception("No data found.")
Else
Dim Common_name = CType(result.Properties("cn")(0), String)
Response.Write("this user is : " & Common_name)
End If
Catch ex As Exception
Response.Write(ex.Message)
End Tr
-----------------------------------------------------------------------------------------------
also it's very unclear to me that where to use CN,DC,DN etc in path
parameter of DirectoryEntry() function.
i am new to LDAP and accessing Active Directory from ASP.NET .
i am getting an error
<Error authenticating user. A referral was returned from the server>
as soon as my debugger executes line
Dim search As DirectorySearcher = New DirectorySearcher(entry)
complete code is given belo
-------------------------------------------------------------------------------------------
Dim _path As String = "LDAP://mercury/cn=users,dc=local" 'Path to your
LDAP directory server
Dim domain = TextBox1.Text 'contains--- XXX , our
domain
Dim username = TextBox2.Text 'contains--- sama ,
existing user
Dim pwd = TextBox3.Text 'contains ---abc ,
sama's pwd
Dim domainAndUsername As String = domain & "\" & username
Dim entry As DirectoryEntry = New DirectoryEntry(_path,
domainAndUsername, pwd)
Try
Dim search As DirectorySearcher = New DirectorySearcher(entry)
search.Filter = "(SAMAccountName=" & username & ")"
search.PropertiesToLoad.Add("cn")
Dim result As SearchResult = search.FindOne()
If (result Is Nothing) Then
Throw New Exception("No data found.")
Else
Dim Common_name = CType(result.Properties("cn")(0), String)
Response.Write("this user is : " & Common_name)
End If
Catch ex As Exception
Response.Write(ex.Message)
End Tr
-----------------------------------------------------------------------------------------------
also it's very unclear to me that where to use CN,DC,DN etc in path
parameter of DirectoryEntry() function.