Skip to main content

SharePoint 2013 CSOM Error : Custom Login Page (Forms Based / Mixed mode authentication)

If you have a SharePoint On Premise installation with a Custom Login Page , you might encounter issues working with CSOM. The error would be primarily related to Authentication Failure. The following solution worked for me.

Step 1: The Custom Login Page should be placed in IIS Virtual Directory.

As a general practise the custom login page is normally placed in the 15 Hive Layouts folder. Move/Copy the ASPX file of your custom login page from the 15 hive layouts folder to  the following folder in IIS Virtual directory of the concerned Web Application:

“C:inetpubwwwrootwssVirtualDirectories<yoursite>_forms”

Step 2: Edit the Custom Login page file to make sure the master page url is correct.

After the movement of the ASPX file, open the file in a notepad and check for the MasterPageFile value and change it to the following =”~/_layouts/15/simple.master“.

Step 3: Change the Custom Login Page Url in Central Administration.

Navigate to Central Admin and change the Url defined in Custom Login Page for the Web App ( Manage Web Application –> Select Web App –> Authentication Providers) to the following :     “~/_forms/customlogin.aspx”

Step 4: For Mixed Mode Authentication Only.

If you are using Forms based authentication , you are already ready to go , however if you have mixed mode authentication then make sure to add the following event handler in the CSOM code :

ClientContext clientContext = new ClientContext(“http://servername/“);
clientContext.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>(clientContext_ExecutingWebRequest);
Web site = clientContext.Web;
clientContext.Load(site);
clientContext.ExecuteQuery();

static void clientContext_ExecutingWebRequest(object sender, WebRequestEventArgs e)
{
                    e.WebRequestExecutor.WebRequest.Headers.Add(“X-FORMS_BASED_AUTH_ACCEPTED”, “f”);
}

CSOM should work fine now !!

Comments

Popular posts from this blog

Llamhub SnowflakeReader: A Loader to query and chat Snowflake Data in your LLM Applications

  Snowflake Loader for LLM Recently my second contribution to Llamaindex "SnowflakeReader" was merged to Lllamahub repository. This loader connects to Snowflake (using SQLAlchemy under the hood). The user specifies a query and extracts Document objects corresponding to the results. This loader is designed to be used as a way to load data into  LlamaIndex  and/or subsequently used as a Tool in a  LangChain  Agent.  Usage Option 1: Pass your own SQLAlchemy Engine object of the database connection Here's an example usage of the SnowflakeReader. from llama_index import download_loader SnowflakeReader = download_loader ( 'SnowflakeReader' ) reader = SnowflakeReader ( engine = your_sqlalchemy_engine , ) query = "SELECT * FROM your_table" documents = reader . load_data ( query = query ) Option 2: Pass the required parameters to esstablish Snowflake connection Here's an example usage of the SnowflakeReader. from llama_index import down...

FTP C# Error : “The remote server returned an error: (530) Not logged in ."

  Recently working on a FTP solution using C# , i encountered an error  “ The  remote server returned an error: (530) Not logged in.” The code i used was following: FtpWebRequest request = (FtpWebRequest)WebRequest.Create( ftp://xxxxxx/file.txt ); request.Method = WebRequestMethods.Ftp.UploadFile request.Credentials = new NetworkCredential(usernameVariable, passwordVariable); What was more bewildering was if i modified the code to following, the solution was working fine. But this for obvious reasons is not an option as the username cannot be hardcoded //works but implausible to use in realtime solutions request.Credentials = new NetworkCredential("dmn/#gsgs", password);  Some googling revealed that special charcters create issues in the NetworkCredential Object. Hence some playing around worked for me, and it works irrespective of wether i do a FTPWebRequest or WebRequest. Solution: Instantiate NetworkCredential object with three paramters (username, pass...

Happy Anniversary

Dec 2010, 6.15 PM, Thoraipakkam, Chennai Gavin alights from the shared auto, thinking to himself, "for gods sake its my first date ever and can I for once afford to have a non-creased t shirt travelling in this over cramped vehicle, great choice."   His mind shifts to the attire selection, "well this is my best , I wore this in Helsinki , Blue Levi Jeans , Black Puma T-Shirt albeit all purchased on discount from t-nagar sarvana stores. Are these fake ? I don’t want to know the answer," he thinks to himself. He looks down on his most dear possession his black fossil watch, time is 6.25. We have been meeting regularly in office, however this is the moment of truth. "Time to call Rachel buddy," he says to himself. As he reaches to his phone and the thought of calling Rachel races through his mind, his heart starts pounding at a speed he had felt only once - as a 6th grade student in military school when he had to jump and climb the 10 feet wall of the insu...