473,414 Members | 1,690 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,414 software developers and data experts.

Using LDAP in a web service

I am attempting to use LDAP to retrieve a list of users from within a web
service. When the FindAll() method is invoked, I receive the following
exception: "The specified domain either does not exist or could not be
contacted."

The code that does not work from within the web service works fine from
within a Windows forms application, so my first guess is that the issue is
security related.

Any ideas on how to use LDAP from within a web service?

Thanks for your help.

Chris

Here is the relevant code from the web service:

DirectorySearcher ds = new DirectorySearcher();
ds.SearchRoot = new DirectoryEntry(""); // start searching from local domain
ds.Filter = String.Format("(&(objectCategory=user)(name={0}))" ,
txtUserName.Text);
ds.PropertyNamesOnly = true;
ds.PropertiesToLoad.Add("name");
ds.PropertiesToLoad.Add("SAMAccountName");
ds.SearchScope = SearchScope.Subtree;
ds.CacheResults = false;
ds.ReferralChasing = ReferralChasingOption.None;
ds.Sort = new SortOption("name", SortDirection.Ascending);

// start searching
SearchResultCollection src = ds.FindAll();
Mar 27 '06 #1
2 2473
>I am attempting to use LDAP to retrieve a list of users from within a web
service. When the FindAll() method is invoked, I receive the following
exception: "The specified domain either does not exist or could not be
contacted."


This either means your LDAP path is invalid (but since you didn't
specify any, that's not likely :-), or then you have an issue with
permissions (most likely). Most likely, the user context the web
service runs under is not privileged to reach into your corporate AD.

I would assume that if used from a web service, you'll need to provide
explicit credentials to use in your LDAP query. You can do this by
instantiating the DirectoryEntry for the root of your search
separately:

DirectorySearcher ds = new DirectorySearcher();

DirectoryEntry deRoot = new
DirectoryEntry("LDAP://yourserver01.yourdomain.com/ou=SomeOU,dc=yourdomain,dc=com",
"your user name", "your user password", AuthenticationTypes.Secure);

ds.SearchRoot = deRoot;
and so forth....

Provided that user you specify is privileged enough to query the AD,
you should be able to run this code and get data back.

Marc
Mar 27 '06 #2
Thanks Marc, I think that did it.

Chris

"Marc Scheuner" wrote:
I am attempting to use LDAP to retrieve a list of users from within a web
service. When the FindAll() method is invoked, I receive the following
exception: "The specified domain either does not exist or could not be
contacted."


This either means your LDAP path is invalid (but since you didn't
specify any, that's not likely :-), or then you have an issue with
permissions (most likely). Most likely, the user context the web
service runs under is not privileged to reach into your corporate AD.

I would assume that if used from a web service, you'll need to provide
explicit credentials to use in your LDAP query. You can do this by
instantiating the DirectoryEntry for the root of your search
separately:

DirectorySearcher ds = new DirectorySearcher();

DirectoryEntry deRoot = new
DirectoryEntry("LDAP://yourserver01.yourdomain.com/ou=SomeOU,dc=yourdomain,dc=com",
"your user name", "your user password", AuthenticationTypes.Secure);

ds.SearchRoot = deRoot;
and so forth....

Provided that user you specify is privileged enough to query the AD,
you should be able to run this code and get data back.

Marc

Mar 27 '06 #3

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

Similar topics

1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
0
by: Ram | last post by:
Hi All How to use C# for Authenticating a NDS server using LDAP. please give me a solution ASAP Thanks, Ram
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
0
by: Robert Jones | last post by:
Our company has our contact data in a SQL Server database. I would like to be able to publish this data as an LDAP service - so for example it becomes available in Outlook. Can anyone point me at...
1
by: Information | last post by:
Hi, I am doing a course project now for practive xml. I heard from somewhere that xml request can go through firewall. currently in our school there is a firewall which only can log on by vpn when...
4
by: karpagam | last post by:
Since WebServices are a standardized way to invoke a method of another application over the internet, is there a way to integrate two different applications running on different platforms (Say a...
2
by: Jonathan Woods | last post by:
Hi there, I have encountered problem of losing data sending over internet using web service. I consume web service that connected Oracle Database. I submit 687 SOAP Messages to 1 Web Method...
2
by: Jay | last post by:
Hi, This is Jay Mehta. I have this problem when using LDAP. I extract names and EmailId's of all those present from LDAP and populate in a datagrid. Now when run locally, it is running...
3
by: Robert Iver | last post by:
Hello, I am developing an application in C# using VS .NET 2005 that will be accessing and updating Active Directory via LDAP. So, far I have written the main portions, but now I am stuck on the...
1
by: kashok | last post by:
Hi all, What is the use of using our own web service in asp.net instead of using ordinary class files for defining functions.. what is the benefit of using web service....... Thnk u!
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.