My view's code[_LoginPartial.cshtml] is like below. I want to show more details like department. How to do it? I succeed in getting departments in IdentityModels.cs. But I don't know how to use it in view.
IdentityModels.cs
var directoryEntry = new System.DirectoryServices.DirectoryEntry();
var directorySearcher = new System.DirectoryServices.DirectorySearcher(directoryEntry);
directorySearcher.Filter = string.Format("(&(objectClass=user)(SamAccountName={0}))", mADUser.SamAccountName);
var result = directorySearcher.FindOne();
var entry = result.GetDirectoryEntry();
var (string)mADUserDirectoryEntry.Properties["department"].Value;
_LoginPartial.cshtml
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
using (Html.BeginForm("LogOff", "Login", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
<ul class="nav navbar-nav navbar-right">
<li>
@Html.ActionLink("Hi" + User.Identity.GetUserName(), "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage", @style = "color: white" })
<a href="javascript:document.getElementById('logoutForm').submit()">ログオフ</a>
</li>
<li></li>
</ul>
}
}