本文介绍了从Provider托管应用程序验证Azure上托管的SharePoint 2013的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
有没有办法通过提供商托管应用对Azure上托管的SharePoint 2013网站的用户进行身份验证?
Is there a way to authenticate users to a SharePoint 2013 site hosted on Azure from Provider hosted app?
谢谢,
Sowmya
推荐答案
嗨Sowmya,
Hi Sowmya,
对于SharePoint在线,我们可以执行以下操作。
For SharePoint online, we can do as below.
public ClientContext Auth(String username, String pwd,string siteURL) { ClientContext context = new ClientContext(siteURL); Web web = context.Web; SecureString passWord = new SecureString(); foreach (char c in pwd.ToCharArray()) passWord.AppendChar(c); context.Credentials = new SharePointOnlineCredentials(username, passWord); try { context.Load(web); context.ExecuteQuery(); Console.WriteLine("Olla! from " + web.Title + " site"); return context; } catch (Exception e) { Console.WriteLine("Something went wrong in Auth Module" + e); Console.ReadKey(); return null; } }
对于SharePoint 2013,我们可以执行以下操作。
For SharePoint 2013, wo can do as below.
public ClientContext Auth(String username, String pwd, string domain, string siteURL) { ClientContext context = new ClientContext(siteURL); Web web = context.Web; context.Credentials = new NetworkCredential(username, pwd, domain); try { context.Load(web); context.ExecuteQuery(); Console.WriteLine("Olla! from " + web.Title + " site"); return context; } catch (Exception e) { Console.WriteLine("Something went wrong in Auth Module" + e); Console.ReadKey(); return null; } }
祝你好运,
Lee Liu
更多推荐
从Provider托管应用程序验证Azure上托管的SharePoint 2013
发布评论