[RESOLVED]MVC 5 Display Common Name from Active Directory instead of Username when using Windows Authentication C#

Hi.. I am brand new to MVC and have just created a new project in VS 2013..

I have not yet added anything to the project, but even if I run it I can see the (Hello, DC1/jbloggs) in the page header. What I would like to be able to do is interrogate AD with the username and bring back the CN and department and display it. As the project
is Intranet based, I don’t really want to use AD to authenticate.

I see that the username is called as Hello, @User.Identity.Name from the _Layout.cshtml file under the Shared View.

Do I need to create a new controller or would the code sit inside the HomeControllers.cs

I have seen lots of coding that will bring back info from AD, but would appreciate any help as to where this sits within the project and where the retrieved information would sit

Hi Fusewire40,

If it display common name, you need have the logic to get current user’s detail information through principals.

There is a thread that can help you:

# Getting Active Directory Info when using Windows Authentication?

http://stackoverflow.com/questions/4961073/getting-active-directory-info-when-using-windows-authentication

Best Regards

Starain

Leave a Reply