I have MVC3 project whit claim based authentication.
I've managed to get the sign in to work.
What I want to do now is to fill a DropDownList
with with groups, then another DropDownlist
with users belonging to this group.
As of now, I fill the DropDownlist
with users which are from my local database.
This my method for getting the users from a certain office
private static void GetUsers(UsersContext.Format wFormat)
{
new UsersContext(new Uri("http://site/api/users"), wFormat)
.Users
.Where(x => x.Office.Equals("HomeOffice"))
.ToList()
.ForEach(
item =>
{
var user = item.DisplayName;
});
}
This how my controller get filled now:
public ActionResult Create()
{
var model = new TaskViewModel();
var subjectypes = createNKIRep.GetAllSubjectTypesById();
var customer = createNKIRep.GetAllCustomersByID();
var teams = createNKIRep.GetAllTeamsByID();
var users = createNKIRep.GetAllUsersByID();
model.Teams = new SelectList(teams, "Id", "Name");
model.Users = new SelectList(users, "Id", "Name");
model.SubjectTypes = new SelectList(subjectypes, "Id", "Name");
model.Company = new SelectList(customer, "Id", "CompanyName");
}
return View(model);
This my view where I fill the dropdownlist
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<h4>Get users to customer</h4>
<legend></legend>
<p>Subjecttype</p>
<div class="editor-field">
@Html.DropDownListFor(m => m.SubjectTypeName, Model.SubjectTypes, "Subjecttype", new { @class = "selectstyle" })
@Html.ValidationMessageFor(model => model.SubjectTypeName)
</div>
<p>Team</p>
<div class="editor-field">
@Html.DropDownListFor(model => model.TeamName, Model.Teams, "Team", new { @class = "selectstyle"})
@Html.ValidationMessageFor(model => model.TeamName)
</div>
<p>Users</p>
<div class="editor-field">
@Html.DropDownListFor(model => model.UserName, Model.Users, "Users", new { @class = "selectstyle"})
@Html.ValidationMessageFor(model => model.UsersName)
</div>
<p>Customer</p>
<div class="editor-field">
@Html.DropDownListFor(model => model.CompanyName, Model.Company, "Company", new { @class = "selectstyle" })
@Html.ValidationMessageFor(model => model.CompanyName)
</div>
So my problem is, that I don't know how to fill the Dropdownlist
with the values from my AD using restful service. Any idea how it can be done?