Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Get the AD department field

Posted on 2011-02-22
2
Medium Priority
?
1,661 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
[X]
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
2 Comments
 
LVL 12

Accepted Solution

by:
geowrian earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

597 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