5

I am prototyping a tool that runs every few minutes and goes off to an office 365 site and to retrieve and then process information.

At the moment I have started with the MSDN guide "Remote Authentication in SharePoint Online Using Claims-Based Authentication" which points to a very helpful code sample that gets a clientcontext object based on a user logging in and then extracts the cookie.

I want to be able to run my code within task scheduler, so that you will be able to specify the office username and password in a configuration somewhere.

Does anyone have any code that will do this or a starting point. something like

using (ClientContext ctx = SomeClass.GetContext(targetSiteUrl, username, password))
{
    if (ctx != null)
    {
        //dostuffhere
    }
}

I have seen this blog post Automatic Login for SharePoint using Claims authentication but the code on the site doesn't appear to be complete / I cannot get it working

Just to note that I am referring to the current release of office 365 (based on 2010) and not the newly available beta of 2013

Ottavio Campana
  • 4,088
  • 5
  • 31
  • 58
Buzzby
  • 291
  • 1
  • 3
  • 15
  • I may have found the answer. I will be in a position to implement on Wednesday this week. http://blogs.msdn.com/b/cjohnson/archive/2011/05/14/part-2-headless-authentication-with-sharepoint-online-and-the-client-side-object-model.aspx – Buzzby Sep 10 '12 at 14:06

3 Answers3

1

so, are you wanting to allow a user to access something without them being a registered user in SharePoint? if so, you may want to look into elevating the current users privileges in code.

haydnD
  • 2,225
  • 5
  • 27
  • 61
  • That is not quite what i'm trying to do. I don't think you can elevate code via the Client side object model. I still need a way of getting the initial clientContext object – Buzzby Sep 04 '12 at 15:26
1

Can confirm that this post here has the answer. ou use the MSOnlineHelper class to do the headless authentication

Buzzby
  • 291
  • 1
  • 3
  • 15
1

Use the SharePointOnlineCredentials class to instantiate clientContext.Credentials.

The SharePointOnlineCredentials class represents an object that provides credentials to access SharePoint Online resources.

Warlock
  • 7,321
  • 10
  • 55
  • 75