Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > More AD Query Questions - C# - 3.5 Framework

Reply
Thread Tools

More AD Query Questions - C# - 3.5 Framework

 
 
greg.hart@alpinebiomed.com
Guest
Posts: n/a
 
      04-03-2009
Hello all,

I am using the code below to query data from AD. Everything working
well, but I wanted to get some additional data like: title, dept,
pager, etc. These don't seem to appear as properties of
UserPrincipal. Is it possible to retrieve them or do I need to use
the DirectorySearcher class from the 2.0 framework to retrieve these
values.

Thanks.

PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
<Domain>,<UserName>,<Password>);
UserPrincipal u = new UserPrincipal(ctx);
u.Enabled = true;
u.Name = "*";
u.VoiceTelephoneNumber = "*";


PrincipalSearcher ps = new PrincipalSearcher(u);
PrincipalSearchResult<Principal> fr = ps.FindAll();


foreach (UserPrincipal usr in fr)
{


Response.Write(usr.DisplayName + "&nbsp;&nbsp;" +
usr.VoiceTelephoneNumber + "<br />");


}


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      04-13-2009
On 3 Apr., 23:48, (E-Mail Removed) wrote:
> Hello all,
>
> I am using the code below to query data from AD. *Everything working
> well, but I wanted to get some additional data like: title, dept,
> pager, etc. *These don't seem to appear as properties of
> UserPrincipal. *Is it possible to retrieve them or do I need to use
> the DirectorySearcher class from the 2.0 framework to retrieve these
> values.
>
> Thanks.
>
> *PrincipalContext ctx = new PrincipalContext(ContextType.Domain,
> <Domain>,<UserName>,<Password>);
> * * * * * * UserPrincipal u = new UserPrincipal(ctx);
> * * * * * * u.Enabled = true;
> * * * * * * u.Name = "*";
> * * * * * * u.VoiceTelephoneNumber = "*";
>
> * * * * * * PrincipalSearcher ps = new PrincipalSearcher(u);
> * * * * * * PrincipalSearchResult<Principal> fr = ps.FindAll();
>
> * * * * * * foreach (UserPrincipal usr in fr)
> * * * * * * {
>
> * * * * * * * * Response.Write(usr.DisplayName + "&nbsp;&nbsp;" +
> usr.VoiceTelephoneNumber + "<br />");
>
> * * * * * * }


Hi Greg,

UserPrincipal has following properties:
http://msdn.microsoft.com/en-us/libr...roperties.aspx

if you need more, use DirectorySearcher, you will find many examples
on MSDN

Hope this helps
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kamaelia 0.4.0 RELEASED - Faster! More Tools! More Examples! More Docs! ;-) Michael Python 4 06-26-2006 08:00 AM
Installing 1.1 Framework and 2.0 Framework on the same web server Mark ASP .Net 4 11-17-2005 03:30 PM
With a Ruby Yell: more, more more! Robert Klemme Ruby 5 09-29-2005 06:37 AM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM
COMInterop does not work in Framework 1.1 without Framework 1.0 Anatoly Volodko ASP .Net 1 08-14-2003 08:11 PM



Advertisments