Ejemplo n.º 1
0
 /// <summary>
 /// Connect using the parameter set APPONLYAAD
 /// </summary>
 /// <returns>PnPConnection based on the parameters provided in the parameter set</returns>
 private PnPConnection ConnectAppOnlyAad()
 {
     if (ParameterSpecified(nameof(CertificatePath)))
     {
         //WriteWarning(@"Your certificate is copied by the operating system to c:\ProgramData\Microsoft\Crypto\RSA\MachineKeys. Over time this folder may increase heavily in size. Use Disconnect-PnPOnline in your scripts remove the certificate from this folder to clean up. Consider using -Thumbprint instead of -CertificatePath.");
         return(PnPConnectionHelper.InitiateAzureADAppOnlyConnection(new Uri(Url), ClientId, Tenant, CertificatePath, CertificatePassword, TenantAdminUrl, NoTelemetry, AzureEnvironment));
     }
     else if (ParameterSpecified(nameof(Certificate)))
     {
         return(PnPConnectionHelper.InitiateAzureAdAppOnlyConnectionWithCert(new Uri(Url), ClientId, Tenant, TenantAdminUrl, NoTelemetry, AzureEnvironment, Certificate));
     }
     else if (ParameterSpecified(nameof(CertificateBase64Encoded)))
     {
         return(PnPConnectionHelper.InitiateAzureAdAppOnlyConnectionWithCert(new Uri(Url), ClientId, Tenant, TenantAdminUrl, NoTelemetry, AzureEnvironment, CertificateBase64Encoded));
     }
     else
     {
         throw new ArgumentException("You must either provide CertificatePath, Certificate or CertificateBase64Encoded when connecting using an Azure Active Directory registered application");
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Connect using the parameter set APPONLYAADThumb
 /// </summary>
 /// <returns>PnPConnection based on the parameters provided in the parameter set</returns>
 private PnPConnection ConnectAppOnlyAadThumb()
 {
     return(PnPConnectionHelper.InitiateAzureADAppOnlyConnection(new Uri(Url), ClientId, Tenant, Thumbprint, TenantAdminUrl, NoTelemetry, AzureEnvironment));
 }