Ejemplo n.º 1
0
        /// <summary>
        /// Connect using provided credentials or the current credentials
        /// </summary>
        /// <returns>PnPConnection based on credentials authentication</returns>
        private PnPConnection ConnectCredentials(PSCredential credentials)
        {
            if (!CurrentCredentials && credentials == null)
            {
                credentials = GetCredentials();
                if (credentials == null)
                {
                    credentials = Host.UI.PromptForCredential(Resources.EnterYourCredentials, "", "", "");

                    // Ensure credentials have been entered
                    if (credentials == null)
                    {
                        // No credentials have been provided
                        return(null);
                    }
                }
            }

            return(PnPConnectionHelper.InstantiateSPOnlineConnection(new Uri(Url),
                                                                     credentials,
                                                                     TenantAdminUrl,
                                                                     NoTelemetry,
                                                                     AzureEnvironment));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Connect using the parameter set APPONLYCLIENTIDCLIENTSECRETURL
 /// </summary>
 /// <returns>PnPConnection based on the parameters provided in the parameter set</returns>
 private PnPConnection ConnectAppOnlyClientIdCClientSecretUrl()
 {
     return(PnPConnectionHelper.InstantiateSPOnlineConnection(new Uri(Url), AADDomain, ClientId, ClientSecret, TenantAdminUrl, false, AzureEnvironment));
 }