1

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?

ps__
  • 365
  • 1
  • 4
  • 19
  • Your question is not clear. What RESTful service are you talking about? Which part are you have problems with? Calling a RESTful service or designing cascading dropdown lists so that when the user chooses a group in the first ddl the second ddl is filled with the corresponding users? – Darin Dimitrov May 03 '12 at 08:11
  • My problem is not calling the RESTful service, my problem is how to fill my dropdownlist with the corresponding users. The service is MVC 4 Web API.. – ps__ May 03 '12 at 08:15
  • 1
    Take a look at the following example: http://stackoverflow.com/a/4459084/29407 – Darin Dimitrov May 03 '12 at 08:21

0 Answers0