我试图停止Active Directory在视图中显示属于组测试的某些帐户。例如,我不想显示SamAccountName =“ Doman Users”
C#
public ActionResult Index(string username)
{
username = "test";
string[] output = null;
// username = sssftappdev;
using (var ctx = new PrincipalContext(ContextType.Domain))
using (var user = UserPrincipal.FindByIdentity(ctx, username))
{
if (user != null)
{
output = user.GetGroups()
.Select(x => x.SamAccountName)
.ToArray();
}
}
return View(output);
}
查看
<table id="tbldirectory" class="table table-striped table-bordered table-hover"> <thead>
<tr>
<th></th>
<th>
@Html.Label("Group Name")
</th>
</tr>
</thead>
<tbody>
@foreach (var output in Model)
{
<tr>
<th>
@Html.ActionLink("View", "Index", "ActiveDirectoryMember", new { id = output }, new { @class = "btn btn-xs btn-primary" }) |
</th>
<th>@output</th>
</tr>
}
</tbody>
</table>