We help IT Professionals succeed at work.
Get Started

Roles validation from Windows authentication

Dukster131
Dukster131 asked
on
256 Views
Last Modified: 2012-06-27
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

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE