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

Querying Active Directory Application Mode (ADAM)...

Hello,

I am trying to query ADAM using the ActiveDirectoryMembershipProvider in my
ASP.NET 2.0 application, but have been unsuccessful. I have followed the
steps in these blog posts, but still am not able to query ADAM. Every time
I make a call to login, using the Membership.ValidateUser method, I keep
getting a false value. I have tried many different variations of the
username including "localhost\myuseraccount", "myuseraccount@localhost" ,
and just "myuseraccount", but none seem to work.

http://erlend.oftedal.no/blog/?blogid=6

http://blogs.msdn.com/donovanf/archi...ntication.aspx

I tried to see if I could just get a list of users using the
Membership.GetAllUsers() method, but this is returning 0 user accounts
(although I have 2 setup in ADAM).

I took another step back and just tried using the classes in the
System.DirectoryServices namespace to try to enumerate the objects in ADAM.
Again I was unsuccessful. Because I re-read the articles explaining how to
do this several times, and made sure my code was a match, I tried to backup
yet again, and put the code in a WinForms application. IT WORKED! So my
question is, why does the following code work in a WinForms application, but
not an ASP.NET application????? (my guess is something to do with Code
Access Security):

int portNumber = 389; // put the correct port number here.

String serverName = "localhost"; // put the correct servername here.

String partitionDir = "OU=Users,O=TestDirectory"; //put the correct
partition distinguished name.

DirectoryEntry ent = new

DirectoryEntry("LDAP://" + serverName + ":" + portNumber.ToString() + "/" +
partitionDir);

foreach (DirectoryEntry child in ent.Children)

{

Console.WriteLine(child.Name);

}
Apr 12 '07 #1
3 2789
Have you tried <identity impersonate="true" /in your web config file ?
This means that the asp.net process that runs your web site will no longer
run under the Network Service account (Win2003) or ASPNET account in XP which
probably don't have access to your active directory, but with your credentials
(machine\user assuming your using windows authentication <authentication
mode="Windows" />) which probably do have access to ADAM.
You could also have a look at http://blogs.msdn.com/alikl/archive/...ransition.aspx
where it investigates a senario similar to your own.

HTH,

--
Konstantinos Pantos,
Software Engineer
Microsoft MVP [ASP.NET]
http://kostas.pantos.name
http://blog.pantos.name
Hello,

I am trying to query ADAM using the ActiveDirectoryMembershipProvider
in my ASP.NET 2.0 application, but have been unsuccessful. I have
followed the steps in these blog posts, but still am not able to query
ADAM. Every time I make a call to login, using the
Membership.ValidateUser method, I keep getting a false value. I have
tried many different variations of the username including
"localhost\myuseraccount", "myuseraccount@localhost" , and just
"myuseraccount", but none seem to work.

http://erlend.oftedal.no/blog/?blogid=6

http://blogs.msdn.com/donovanf/archi...adam-with-acti
vedirectorymembershipprovider-for-forms-authentication.aspx

I tried to see if I could just get a list of users using the
Membership.GetAllUsers() method, but this is returning 0 user accounts
(although I have 2 setup in ADAM).

I took another step back and just tried using the classes in the
System.DirectoryServices namespace to try to enumerate the objects in
ADAM. Again I was unsuccessful. Because I re-read the articles
explaining how to do this several times, and made sure my code was a
match, I tried to backup yet again, and put the code in a WinForms
application. IT WORKED! So my question is, why does the following
code work in a WinForms application, but not an ASP.NET
application????? (my guess is something to do with Code Access
Security):

int portNumber = 389; // put the correct port number here.

String serverName = "localhost"; // put the correct servername here.

String partitionDir = "OU=Users,O=TestDirectory"; //put the correct
partition distinguished name.

DirectoryEntry ent = new

DirectoryEntry("LDAP://" + serverName + ":" + portNumber.ToString() +
"/" + partitionDir);

foreach (DirectoryEntry child in ent.Children)

{

Console.WriteLine(child.Name);

}

Apr 13 '07 #2
I have changed my Web.Config to impersonate my user account (which has
Administrator rights on the box), now I am not getting the COM Exception
errors I was getting before, but when I try to enumerate the children (same
code I originally posted), I am getting a 0 Count value... Sort of like I
get when I use the Membership.GetAllUsers() method to get all the users.

Is there something else I am missting to be able to get my ASP.NET
application working with ADAM?

TIA!


"Konstantinos Pantos" <kp*****@dolnet.grwrote in message
news:d9*************************@msnews.microsoft. com...
Have you tried <identity impersonate="true" /in your web config file ?
This means that the asp.net process that runs your web site will no longer
run under the Network Service account (Win2003) or ASPNET account in XP
which probably don't have access to your active directory, but with your
credentials (machine\user assuming your using windows authentication
<authentication mode="Windows" />) which probably do have access to ADAM.
You could also have a look at
http://blogs.msdn.com/alikl/archive/...ransition.aspx
where it investigates a senario similar to your own.

HTH,

--
Konstantinos Pantos,
Software Engineer
Microsoft MVP [ASP.NET]
http://kostas.pantos.name
http://blog.pantos.name
>Hello,

I am trying to query ADAM using the ActiveDirectoryMembershipProvider
in my ASP.NET 2.0 application, but have been unsuccessful. I have
followed the steps in these blog posts, but still am not able to query
ADAM. Every time I make a call to login, using the
Membership.ValidateUser method, I keep getting a false value. I have
tried many different variations of the username including
"localhost\myuseraccount", "myuseraccount@localhost" , and just
"myuseraccount", but none seem to work.

http://erlend.oftedal.no/blog/?blogid=6

http://blogs.msdn.com/donovanf/archi...adam-with-acti
vedirectorymembershipprovider-for-forms-authentication.aspx

I tried to see if I could just get a list of users using the
Membership.GetAllUsers() method, but this is returning 0 user accounts
(although I have 2 setup in ADAM).

I took another step back and just tried using the classes in the
System.DirectoryServices namespace to try to enumerate the objects in
ADAM. Again I was unsuccessful. Because I re-read the articles
explaining how to do this several times, and made sure my code was a
match, I tried to backup yet again, and put the code in a WinForms
application. IT WORKED! So my question is, why does the following
code work in a WinForms application, but not an ASP.NET
application????? (my guess is something to do with Code Access
Security):

int portNumber = 389; // put the correct port number here.

String serverName = "localhost"; // put the correct servername here.

String partitionDir = "OU=Users,O=TestDirectory"; //put the correct
partition distinguished name.

DirectoryEntry ent = new

DirectoryEntry("LDAP://" + serverName + ":" + portNumber.ToString() +
"/" + partitionDir);

foreach (DirectoryEntry child in ent.Children)

{

Console.WriteLine(child.Name);

}


Apr 13 '07 #3
On Apr 13, 8:28 pm, "Brian McCullough" <nospammin...@test.comwrote:
I have changed my Web.Config to impersonate my user account (which has
Administrator rights on the box), now I am not getting the COM Exception
errors I was getting before, but when I try to enumerate the children (same
code I originally posted), I am getting a 0 Count value... Sort of like I
get when I use the Membership.GetAllUsers() method to get all the users.

Is there something else I am missting to be able to get my ASP.NET
application working with ADAM?

TIA!

"Konstantinos Pantos" <kpan...@dolnet.grwrote in message

news:d9*************************@msnews.microsoft. com...
Have you tried <identity impersonate="true" /in your web config file ?
This means that the asp.net process that runs your web site will no longer
run under the Network Service account (Win2003) or ASPNET account in XP
which probably don't have access to your active directory, but with your
credentials (machine\user assuming your using windows authentication
<authentication mode="Windows" />) which probably do have access to ADAM.
You could also have a look at
http://blogs.msdn.com/alikl/archive/...-flow-through-...
where it investigates a senario similar to your own.
HTH,
--
Konstantinos Pantos,
Software Engineer
Microsoft MVP [ASP.NET]
http://kostas.pantos.name
http://blog.pantos.name
Hello,
I am trying to query ADAM using the ActiveDirectoryMembershipProvider
in my ASP.NET 2.0 application, but have been unsuccessful. I have
followed the steps in these blog posts, but still am not able to query
ADAM. Every time I make a call to login, using the
Membership.ValidateUser method, I keep getting a false value. I have
tried many different variations of the username including
"localhost\myuseraccount", "myuseraccount@localhost" , and just
"myuseraccount", but none seem to work.
>http://erlend.oftedal.no/blog/?blogid=6
>http://blogs.msdn.com/donovanf/archi...adam-with-acti
vedirectorymembershipprovider-for-forms-authentication.aspx
I tried to see if I could just get a list of users using the
Membership.GetAllUsers() method, but this is returning 0 user accounts
(although I have 2 setup in ADAM).
I took another step back and just tried using the classes in the
System.DirectoryServices namespace to try to enumerate the objects in
ADAM. Again I was unsuccessful. Because I re-read the articles
explaining how to do this several times, and made sure my code was a
match, I tried to backup yet again, and put the code in a WinForms
application. IT WORKED! So my question is, why does the following
code work in a WinForms application, but not an ASP.NET
application????? (my guess is something to do with Code Access
Security):
int portNumber = 389; // put the correct port number here.
String serverName = "localhost"; // put the correct servername here.
String partitionDir = "OU=Users,O=TestDirectory"; //put the correct
partition distinguished name.
DirectoryEntry ent = new
DirectoryEntry("LDAP://" + serverName + ":" + portNumber.ToString() +
"/" + partitionDir);
foreach (DirectoryEntry child in ent.Children)
{
Console.WriteLine(child.Name);
}- Hide quoted text -

- Show quoted text -
I have never used that ADAM but sounds like you have a security
problem

What authentication mode do you have in your web.config and what what
authentication method is defined in IIS (Properties - Directory
Security - Authentication Method)?

Apr 13 '07 #4

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

Similar topics

1
by: DEWright_CA | last post by:
I have a plan to use AzMan to manage a application I am developing for a gov. agency. My problem is how do I deploy the security schema once it has been created? I am using DeKlarit to develop the...
0
by: Trey Mitchell | last post by:
I have built a single class in vb.Net to handle all active directory authentication needed in my web app. People can sign into the website with no problem. There is also a second form of...
0
by: Brian Mitchell | last post by:
Is there any way to return active directory objects from the object's guid? My basic problem is that I don't know the appropriate search filters. Does anyone know of any sites that list them? (like...
0
by: Gary | last post by:
I'm creating an Infopath form and I need to query Active Directory to obtain some data. Here is the code I'm using (obtained from sample code from MSDN) Private Shared domainADsPath As String =...
4
by: IainM | last post by:
How can I enumerate AD objects (only in a given OU, not sub OUs) using the DirectoryEntry object? Let me know of this is the wrong forum for this question. Thanks, Iain
0
by: hellosibba | last post by:
i am trying to enumerate and query the organization Domain controller to get all the domains and its corresponding users in it. i also want to query the user's information like full name,...
3
by: MuZZy | last post by:
Hi, I'm trying to find a way to call a standard ActiveDirectory search dialog from my C# app, so i can pick a domain or computer user an dreturn it to the app. It's a search like one showing...
0
by: gdltec | last post by:
I have an ASP page that needs to be populated with employee data from Active Directory (i.e. Name, email, manager, etc), can anyone help me out on how to acomplish this? I just need to know how to...
4
by: jllg2000 | last post by:
I got this query: CREATE VIEW viewADContacts AS SELECT , SN , ST State FROM OPENQUERY( ADSI2, 'SELECT Name, SN, ST FROM ''LDAP://presidencia.local/CN=Users,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.