用于连接到Sharepoint Online的用户凭据

时间:2019-06-12 05:18:46

标签: c# vb.net office365 sharepoint-online

我有一个分发给各个用户的Windows应用程序。我需要将应用程序连接到SharePoint Online。我已经做到了这一点,但是我想避免用户每次打开应用程序时都必须输入用户名/密码。

SharePoint用户与他们的Windows帐户使用相同的密码,是否需要传递密码而无需用户手动输入密码?

此外,针对365的oauth身份验证会自动使用户登录。因此,如果我向他们提供URL,则无需登录即可查看,但我仍然需要通过编程方式进行操作的凭据。

Dim filename As Uri = New Uri(serverURL)
    Dim theSecureString As New Security.SecureString
    theSecureString = New System.Net.NetworkCredential("", UserPword).SecurePassword



    Dim server As String = filename.AbsoluteUri.Replace(filename.AbsolutePath, "")
    Dim serverrelative As String = filename.AbsolutePath
    Dim clientContext As Microsoft.SharePoint.Client.ClientContext = New Microsoft.SharePoint.Client.ClientContext(server)
    clientContext.Credentials = New Microsoft.SharePoint.Client.SharePointOnlineCredentials(UserName, theSecureString)
    Dim f As Microsoft.SharePoint.Client.FileInformation = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, serverrelative)
    clientContext.ExecuteQuery()

0 个答案:

没有答案