Connecting Tech Pros Worldwide Forums | Help | Site Map

get user details from Active Directory

Dan Nash
Guest
 
Posts: n/a
#1: Nov 18 '05
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

srini
Guest
 
Posts: n/a
#2: Nov 18 '05

re: get user details from Active Directory


hi nash,
you have it all here
http://www.c-sharpcorner.com/DirectoryServices.asp
HTH
srini

"Dan Nash" wrote:
[color=blue]
> 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[/color]
Mike Newton
Guest
 
Posts: n/a
#3: Nov 18 '05

re: get user details from Active Directory


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/parenti...8/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.




Dan Nash wrote:[color=blue]
> 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[/color]
Dan Nash
Guest
 
Posts: n/a
#4: Nov 18 '05

re: get user details from Active Directory


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

"Dan Nash" wrote:
[color=blue]
> 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[/color]
Mike Newton
Guest
 
Posts: n/a
#5: Nov 18 '05

re: get user details from Active Directory


You need to add System.DirectoryServices as a reference.



Dan Nash wrote:[color=blue]
> 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
>
> "Dan Nash" wrote:
>
>[color=green]
>>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[/color][/color]
Closed Thread