How to get LDAP directory server

V

VK

Hello,

We have installed AD and now I want to authenticate the user against AD via
IIS and get the user information via LDAP. However I dont know the LDAP
Directory. How do I get the LDAP directory?

Thanks
 
J

Jan Peter Stotz

VK said:
We have installed AD and now I want to authenticate the user against AD via
IIS and get the user information via LDAP. However I dont know the LDAP
Directory. How do I get the LDAP directory?

You can use this function:

Function GetADsDomainName as String
dim objRootDSE
objRootDSE = GetObject("LDAP://rootDSE")
return objRootDSE.Get("DefaultNamingContext")
End Function

It returns the LDAP-path of your ActiveDirectory:

For Example "dc=yourdomain,dc=com".

Jan
 
V

VK

I tried that and get:

Cannot create ActiveX component.

Private Function GetLDAPEntry() As DirectoryEntry
Dim objRootDSE
objRootDSE = GetObject("LDAP://rootDSE") <-- Error here
Return New
DirectoryEntry(objRootDSE.Get("DefaultNamingContext")) End Function
 
J

Joe Kaplan \(MVP - ADSI\)

In an ASP.NET application, you may need to supply a domain name in your
binding string and some valid credentials in the username and password
parameters. The issue is that in ASP.NET, it is often the case that you are
running under a local machine account whose credentials cannot be used to
access AD directly.

Essentially, what you will want to do is read the Context.User.Identity.Name
property in ASP.NET to get the current user name (will be domain\username),
then pull off the username part and use that in a search filter to search
the domain for that user. The filter would look like
(sAMAccountName=username)

Using PropertiesToLoad on the DirectorySearcher, you can specify which AD
attributes you wish to retrieve and get them back in a SearchResult object.

Depending on the structure of your AD, you may want to search at the domain
level or do a global catalog search at the forest level
(GC://domain.com/xxxxx), depending on whether multiple domains are involved.

HTH,

Joe K.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top