I am using the sample code provided from the MSDN Code Site located here: Remote Authentication using Client Object Model
I am using ADFS v. 2.0 as my Claims Provider and I have configured ADFS for Forms Authentication. The code provided in the sample below works if I do not already have an authenticated Claims Session, in which case, it prompts me for the credentials to log in/access the SharePoint site. However, if I already have an authenticated session, the code simply opens up the SharePoint site directly and never prompts for credentials.
1) First of all, how do I get the code to always prompt for credentials regardless of the state of the current session login?
2) Second of all, is there a way to simply generate the entire FedAuth Token directly without prompting with a User Credentials screen (i.e. can I just pass Username/password credentials and have the code automatically log me in)?
class Program
{
[STAThread]
static void Main(string[] args)
{
//if (args.Length < 1) { Console.WriteLine("SP_Ctx <url>"); return; }
//string targetSite = args[0];
string targetSite = "https://sp2010ent";
using (ClientContext ctx = ClaimClientContext.GetAuthenticatedContext(targetSite))
{
if (ctx != null)
{
ctx.Load(ctx.Web); // Query for Web
ctx.ExecuteQuery(); // Execute
string strListName = "Child";
string strFolderName = "1";
var query = ctx.LoadQuery(ctx.Web.Lists.Where(l => l.Title == strListName));
ctx.ExecuteQuery();
List docLib = query.FirstOrDefault();
string strFolderUrl = string.Format("{0}/{1}/{2}", targetSite, strListName, strFolderName);
docLib.RootFolder.Folders.Add(strFolderUrl);
docLib.Update();
ctx.ExecuteQuery();
}
}
Console.ReadLine();
}
}Please advise.