Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

LDAP using .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tash - 19 Jul 2005 16:26 GMT
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.
Paul Clement - 19 Jul 2005 19:00 GMT
¤ 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)
Patrick.O.Ige - 20 Jul 2005 08:33 GMT
If that doesn't solve it post it to the security FORUM.
Patrick

> ¤ I am having a weird problem. I am trying to use the following code to query
> ¤ active directory.
[quoted text clipped - 20 lines]
> ¤
> ¤ Server Error in '/WaiversEngagements' Application.

¤ --------------------------------------------------------------------------
------
> ¤
> ¤ The specified domain either does not exist or could not be contacted
[quoted text clipped - 8 lines]
> ~~~~
> Microsoft MVP (Visual Basic)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.