How to log-in Programmatically to SharePoint 2013 with Windows Authentication.


  • We want to accomplish to log-in to the SharePoint 2013 site with Windows Authentication similar to the Forms 

    based using a web page programmatically. Since we want to avoid the use of windows dialog box offered by 

    browser which takes the windows authentication credentials in the following format DomainName\UserName 

    and Pasword. Since we have most of internet users, so need a web page as login.

    Whereas I am able to achive the part of scenario after making the following some changes: 

    1> I gave the anonymous access to the default.aspx page under WINDOWS under IDENTITYMODEL 

    2> I wrote the code behind file for the same default.aspx page to Authenticate with Active Directory and 

    Registered the assembly in GAC.
    3> After user enters the credentials, I concatinate Domain Name with "\" with user Name(DomainName

    \UserName) and use the Directory search function to Validate the User against the Active directory users, it 

    works fine and returns true.

    But the code to redirect to sharepoint site(base.RedirectToSuccessUrl()) doesn't work,
    Because I am not able to genrate the token and pass it to the successful url.
    I have tried variety of things but no luck,I am not sure this is doable or not, but I wish if I could pass the token
    to the subsequent Pages and could accomplish the task.

    Is there any sharepoint assembly, I must add.......please help me.

    I hope I am able to explain the issue....Thanking you in advance.

    Sunday, August 24, 2014 11:55 AM


  • Hi Rohan,

    Did you set web application to use the custom login page in its authentication provider in Central Administration?

    Best regards.


    Victoria Xia
    TechNet Community Support

    Wednesday, September 03, 2014 8:51 AM

All replies