Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i need to customize public site and used custom login page for authenticated SharePoint Users.

i am follow below post :

http://community.office365.com/en-us/forums/154/p/57156/207461.aspx#207461

and checked that we can accomplish authenticated using CSOM. so i have used below code.

http://blogs.msdn.com/b/cjohnson/archive/2011/05/14/part-2-headless-authentication-with-sharepoint-online-and-the-client-side-object-model.aspx

here is code :

        string cmdSpoSite = "https://sharepoint-public.sharepoint.com/";
        string cmdUserName = "username@sharepointahm.onmicrosoft.com";
        string cmdPassword = "password";

        helper = new MsOnlineClaimsHelper(
                    cmdUserName,
                    cmdPassword,
                    cmdSpoSite);

        using (ClientContext ctx = new ClientContext(cmdSpoSite))
        {
            ctx.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>(ctx_ExecutingWebRequest);

            if (ctx != null)
            {
                ctx.Load(ctx.Web); // Query for Web
                ctx.ExecuteQuery(); // Execute

                lbltext.Text = ctx.Web.Title;
                //Console.WriteLine(ctx.Web.Title);
            }
        } 

code is worked fine in console app. when moved on webpart of Sandbox solution it does not worked. but when i have used code on webpart in Farm Solution getting worked fine.

please guide we can used it or not?

Thanks

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Not in a sandbox solution no. You could however create the app running on a separate web server / app and call it in a iframe since it's client object model.

The reason it won't work is because the namespaces you require are blocked in sandbox.

share|improve this answer
    
sound like create asmx service or wcf service to accomplish this.Am i right? –  Jigs May 14 '13 at 13:19
    
You don't need to, you can create a new web app for a basic asp.net site and use that for hosting apps. Really this would be a seperate server ideally. Then you can run your csom from there and have it come in a iframe on the page. The use has total transparency as to what is going on. Going forward this is a step towards the 2013 app model which is replacing sandbox. –  Hugh Wood May 14 '13 at 13:34

Your Answer

 
discard

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.