473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

active directory query using directorysearcher

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.
Nov 19 '05 #1
1 1762
Hi Tash,

It seems that the ASPNET account don't have enough permission. You can try
to use impersonate in web.config:

<identity impersonate="true" userName="ImpersonatedID"
password="Password" />

HTH

Elton Wang
el********@hotmail.com
"Tash" wrote:
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.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: huzz | last post by:
I have web application that quaries the Active Directory to get user details.. everything works fine but someday I'll get System.Runtime.InteropServices.COMExection and if I restart the client...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
9
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated...
10
by: huzz | last post by:
I have web application that quaries the Active Directory to get user details.. everything works fine but someday I'll get System.Runtime.InteropServices.COMExection and if I restart the client...
18
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.