get user details from Active Directory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I've got the Username of the logged in user and domain with
Page.User.Identity.Name. It comes in as "domain\user".

Now, I want to query AD to get the users Firstname and Email address. Can
anyone point me in the direction of an article?

Cheers


Dan
 
Use an LDAP search.

Here's the RFC: http://www.faqs.org/rfcs/rfc2254.html

Here are a couple of articles on how to use it:
http://www.wwwcoder.com/main/parentid/272/site/1694/68/default.aspx
http://www.codeproject.com/csharp/ADTester.asp
http://www.codeproject.com/aspnet/adsi1.asp

This one isn't as detailed:
http://www.codeproject.com/vb/net/LDAP_Using_VBnet.asp

Just remember that your logical operators for the filter are in prefix
notation. A search would go something like (&(CN='Dog')(Name='Yada'))
for AND operations, (|...) for OR operations.

The particular AD property that has the user name, I've found, is
sAMAccountName. This may or may not be the same for you. You'll have
to split off the domain name in any case.
 
Thanks guys - all very helpful.

However, I'm now trying to get it working (VC#). Problem I'm getting is it
doesn't seem to recognise the System.DirectoryServices namespace?

It's not in the Intellisense lists, and if I just type it, it says it can't
find it. Any ideas?

Cheers

Dan
 

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

Back
Top