470,647 Members | 1,328 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

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 2637
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by DEWright_CA | last post: by
reply views Thread by Brian Mitchell | last post: by
reply views Thread by Gary | last post: by
4 posts views Thread by IainM | last post: by
1 post views Thread by Korara | last post: by
reply views Thread by warner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.