Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Get the AD department field

Posted on 2011-02-22
2
1,412 Views
Last Modified: 2012-05-11
I can successfully pull out fields from an AD account but unable to get the 'department' field using System.DirectoryServices.AccountManagement for framework 3.5.

The object 'user' that's returned by UserPrincipal does not seem to have a property for this or one that I cannot find. Anyone have a solution instead of using the old System.DirectoryServices model?
using System.DirectoryServices.AccountManagement;

PrincipalContext adPrincipalContext = new PrincipalContext(ContextType.Domain, "MyDomain", "DC=MyDomain,DC=com,DC=au");

UserPrincipal user = UserPrincipal.FindByIdentity(adPrincipalContext, IdentityType.SamAccountName, "aduser");

 lblInfo.Text = "<br>" + user.DisplayName.ToString();
 lblInfo.Text += "<br>" + user.EmailAddress.ToString();

Open in new window

0
Comment
Question by:chris_desborough
2 Comments
 
LVL 12

Accepted Solution

by:
geowrian earned 250 total points
ID: 34957459
0
 
LVL 1

Author Closing Comment

by:chris_desborough
ID: 34957701
Thanks geowrian - works great. Thanks for the tip.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question