SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I Created custom login page .

I use this code for login

if (Membership.ValidateUser(Username.Text, Password.Text))


    SecurityToken tk = SPSecurityContext.SecurityTokenForFormsAuthentication(

        new Uri(SPContext.Current.Web.Url), "ADProvider", null,

        Username.Text, Password.Text);

    if (tk != null)


        SPFederationAuthenticationModule fam = SPFederationAuthenticationModule.Current;


        //look for the Source query string parameter and use that as the redirection

        string src = page.Request.QueryString["Source"];

        if (!string.IsNullOrEmpty(src))


            Response.Redirect(src, false);




            Response.Redirect("/", false);



I add connectionstring and membersgip for webconfig


<add name="AdConn" connectionString="LDAP://domain.local/DC=domain,DC=local" />


<membership defaultProvider="i">





      type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 



      attributeMapUsername="sAMAccountName" />




but when i login , i get

Error: Access Denied

share|improve this question
up vote 1 down vote accepted

Open Central Administration and go to Application hit User Policy ribbon option in the Web Applications Management page having selected your web application. Hit Add Users in the Policy for Web Application dialog. Hit Next in Add Users dialog. Use the Browse button in the Choose Users people picker control. Notice the Select People and Groups dialog that comes up is changed. Noticeable difference is that there are sections like Active Directory, All Users, Forms Auth & Organizations. Type in an active directory user alias and search. There should be 2 results for the same user. Select the user from Forms Auth result.

enter image description here

Now, your Policy for Web Application dialog should look like Image

enter image description here

I use this link. It is useful for me.

share|improve this answer
good that you solved it. Please elaborate a bit in the answer on how this solved your issue. Those external links tend to be shorter lived than our site, so please insert a few lines and then link :-) thx – Anders Rask May 16 '12 at 8:41
Anders Rask♦: ok, Thanks :) – ar.gorgin May 16 '12 at 9:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.