LDAP using .NET


G

Guest

I am having a weird problem. I am trying to use the following code to query
active directory.

Function IsExistInAD(ByVal loginName As String) As Boolean
Dim userName As String = ExtractUserName(loginName)
Dim search As DirectorySearcher = New DirectorySearcher
search.Filter = String.Format("(SAMAccountName={0})", userName)
search.PropertiesToLoad.Add("cn")
Dim result As SearchResult = search.FindOne
If result Is Nothing Then
Return False
Else
Return True
End If
End Function

Where I am passing in DOMAIN\username. Now, the problem is that it works
fine on windows forms. It searches AD and returns true if the username exists
and false if the username doesnt exit in the domain.

But now I have to do the same thing on a webform. And it wont work.
I get:

Server Error in '/WaiversEngagements' Application
--------------------------------------------------------------------------------

The specified domain either does not exist or could not be contacted

Any ideas????

Any and all help would be greatly appreciated.

Thanks.
 
Ad

Advertisements

P

Paul Clement

¤ I am having a weird problem. I am trying to use the following code to query
¤ active directory.
¤
¤ Function IsExistInAD(ByVal loginName As String) As Boolean
¤ Dim userName As String = ExtractUserName(loginName)
¤ Dim search As DirectorySearcher = New DirectorySearcher
¤ search.Filter = String.Format("(SAMAccountName={0})", userName)
¤ search.PropertiesToLoad.Add("cn")
¤ Dim result As SearchResult = search.FindOne
¤ If result Is Nothing Then
¤ Return False
¤ Else
¤ Return True
¤ End If
¤ End Function
¤
¤ Where I am passing in DOMAIN\username. Now, the problem is that it works
¤ fine on windows forms. It searches AD and returns true if the username exists
¤ and false if the username doesnt exit in the domain.
¤
¤ But now I have to do the same thing on a webform. And it wont work.
¤ I get:
¤
¤ Server Error in '/WaiversEngagements' Application.
¤ --------------------------------------------------------------------------------
¤
¤ The specified domain either does not exist or could not be contacted
¤
¤ Any ideas????
¤
¤ Any and all help would be greatly appreciated.


You probably need to turn off Anonymous authentication. Use Basic or Integrated NT instead.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Ad

Advertisements

P

Patrick.O.Ige

If that doesn't solve it post it to the security FORUM.
Patrick

Paul Clement said:
¤ I am having a weird problem. I am trying to use the following code to query
¤ active directory.
¤
¤ Function IsExistInAD(ByVal loginName As String) As Boolean
¤ Dim userName As String = ExtractUserName(loginName)
¤ Dim search As DirectorySearcher = New DirectorySearcher
¤ search.Filter = String.Format("(SAMAccountName={0})", userName)
¤ search.PropertiesToLoad.Add("cn")
¤ Dim result As SearchResult = search.FindOne
¤ If result Is Nothing Then
¤ Return False
¤ Else
¤ Return True
¤ End If
¤ End Function
¤
¤ Where I am passing in DOMAIN\username. Now, the problem is that it works
¤ fine on windows forms. It searches AD and returns true if the username exists
¤ and false if the username doesnt exit in the domain.
¤
¤ But now I have to do the same thing on a webform. And it wont work.
¤ I get:
¤
¤ Server Error in '/WaiversEngagements' Application.
¤ --------------------------------------------------------------------------
------
 

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

Top