I'm working on a site where users authenticate via Active Directory. I can retrieve the users fullname via CurrentUser.Fullname or username via CurrentUser.UserName. That's pretty much it... I would like to retrieve the users e-mailadress as well... and maybe some other info. How can I go about getting this information out of the AD? The site is using CMS 6 R2. What would be the easiest way?
The easiest way is to use the methods in System.DirectoryServices, please see http://msdn.microsoft.com/en-us/library/system.directoryservices.aspx. And then fetch the user as an UserPrincipal, which will have all the properties. If you extend the UserPrincipal object you can get custom properties typed.
I agree with Johan above. Using .NET standard System.DirectoryServices to retrieve additional information about the user is the way to go. Expensive operation so might want to store it in either session or by extending the current user yes...
Thank you... Shall have a look at it!