Link to home
Start Free TrialLog in
Avatar of Dukster131
Dukster131Flag for United States of America

asked on

Roles validation from Windows authentication

I have been struggling for weeks to figure out how to use my roles authentication when using windows authentication in my web application.  My problem is that my users have been entered from a forms login in an application that is not windows authenticated.  However, I also have created an intranet site that uses windows authentication.  Both user names are the same except the windows authentication adds a domain name to the user.identity.name.  So when the application looks for their role it does not find them.  I have tried parsing out the domain name, but have not found a good way to make the application recognize the parsed name as the user identity.  I have tried the following code, but it does not seem to work.


strUser = Context.User.Identity.Name.ToLower();
            string searchString = "\\";
            int startNumber = strUser.IndexOf(searchString) + 1;
            int endNumber = strUser.Length - startNumber;
            strUser = strUser.Substring(startNumber, endNumber);
            
            FormsAuthentication.SetAuthCookie(strUser, false);

            //string strReturnURL = "Login.aspx";
            //if (Request.QueryString["ReturnURL"] != null)
            //{
            //    strReturnURL = Request.QueryString["ReturnURL"];
            //}
            MembershipUser currentUser = Membership.GetUser();
            FormsAuthentication.RedirectFromLoginPage(strUser, false);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Sammy
Sammy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dukster131

ASKER

Thanks that got me on the right track.  The article was a little old because it was still using an older IIS and to look at the solution needed asp.net 1.1 framework.
I still had to do some configurations on my own after observing the solution I was pointed to.