1

I have an application that authorizes against an active directory and this working perfectly. Now what I am trying to do is get the user that is login group name.

I have this method here:

[HttpPost]
        public ActionResult Login(LoginClass model, string ReturnUrl)
        {

            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    if (Url.IsLocalUrl(ReturnUrl) && ReturnUrl.Length > 1 && ReturnUrl.StartsWith("/")
                        && !ReturnUrl.StartsWith("//") && !ReturnUrl.StartsWith("/\\"))
                    {
                        return Redirect(ReturnUrl);
                    }
                    else
                    {
                        string[] test = Roles.GetRolesForUser();
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect");
                }
            }

            return RedirectToAction("Index", "Home");
        } 

now this line: string[] test = Roles.GetRolesForUser(); returns empty. I put a breakpoint and found this message:

The Role Manager feature has not been enabled

I have also added this to my web.config:

<roleManager enabled="true" />

inside system.web inside configuration

What am I doing wrong, I know the groups exist and I just can't get them or how would get the users OU (organization unit)

user979331
  • 11,039
  • 73
  • 223
  • 418
  • Hi, I have same code, look like we've used same tutorial. Have you find solution for this problem? If so, could you maybe write it down? Thanks, M. – Mastenka Apr 19 '16 at 16:25

0 Answers0