Wednesday, December 21, 2016

logging into sharepoint with csom

   #region SECURITY
           
            string userName = this.User.Text;//
            string userPassword = this.pwd.Text;//            if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(userPassword))
            {
               SecureString securePassword = new SecureString();
                    for (int i = 0; i < userPassword.Length; i++)
                    {
                        securePassword.AppendChar(userPassword[i]);
                    }
                if (!this.windows.Checked)
                {

                    SharePointOnlineCredentials creds = new SharePointOnlineCredentials(userName, securePassword);
                    context.Credentials = creds;
                }
                else
                {
                    NetworkCredential creds = new NetworkCredential(userName, securePassword);
                    context.Credentials = creds;
                }
            }

            #endregion

No comments:

Post a Comment