Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2721 from pnp/dev
Browse files Browse the repository at this point in the history
June 2020 Intermediate Release 1
  • Loading branch information
erwinvanhunen authored Jun 9, 2020
2 parents 07637ed + b09e987 commit b812c37
Show file tree
Hide file tree
Showing 17 changed files with 332 additions and 257 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Contributors

## [3.22.2006.1]

Intermediate release due to a fix in the underlying Core Library.

## [3.22.2006.0]

Expand Down
32 changes: 0 additions & 32 deletions Commands/Admin/StartSiteRename.cs

This file was deleted.

39 changes: 29 additions & 10 deletions Commands/Base/ConnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
using System.Security.Cryptography.X509Certificates;
using System.IdentityModel.Tokens.Jwt;
using SharePointPnP.PowerShell.Commands.Enums;
#if !NETSTANDARD2_1
using System.Web.UI.WebControls;
#endif
using SharePointPnP.PowerShell.Commands.Model;
using Resources = SharePointPnP.PowerShell.Commands.Properties.Resources;
#if !NETSTANDARD2_1
using System.Security.Cryptography;
#endif
using System.Reflection;
#if NETSTANDARD2_1
using System.IdentityModel.Tokens.Jwt;
#endif
#if !ONPREMISES
#endif

Expand Down Expand Up @@ -375,8 +376,10 @@ public class ConnectOnline : BasePSCmdlet
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_WEBLOGIN, HelpMessage = "If you want to connect to SharePoint with browser based login. This is required when you have multi-factor authentication (MFA) enabled.")]
public SwitchParameter UseWebLogin;

#if !NETSTANDARD2_1
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_MAIN, HelpMessage = "Specify to use for instance use forms based authentication (FBA)")]
public ClientAuthenticationMode AuthenticationMode = ClientAuthenticationMode.Default;
#endif

[Parameter(Mandatory = false, ParameterSetName = ParameterSet_MAIN, HelpMessage = "If you want to create a PSDrive connected to the URL")]
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_TOKEN, HelpMessage = "If you want to create a PSDrive connected to the URL")]
Expand Down Expand Up @@ -693,10 +696,11 @@ protected void Connect()
connection = ConnectAppOnlyAadCer();
break;

#if !NETSTANDARD2_1
case ParameterSet_GRAPHWITHSCOPE:
connection = ConnectGraphWithScope();
break;

#endif
case ParameterSet_ACCESSTOKEN:
connection = ConnectAccessToken();
break;
Expand Down Expand Up @@ -782,7 +786,7 @@ protected void Connect()
}
}

#region Connect Types
#region Connect Types

/// <summary>
/// Connect using the paramater set TOKEN
Expand Down Expand Up @@ -1036,7 +1040,7 @@ private PnPConnection ConnectAppOnlyAadPem()
#if !NETSTANDARD2_1
return PnPConnectionHelper.InitiateAzureADAppOnlyConnection(new Uri(Url), ClientId, Tenant, PEMCertificate, PEMPrivateKey, CertificatePassword, MinimalHealthScore, RetryCount, RetryWait, RequestTimeout, TenantAdminUrl, Host, NoTelemetry, SkipTenantAdminCheck, AzureEnvironment);
#else
throw new NotImplementedException();
return PnPConnectionHelper.InitiateAzureADAppOnlyConnection(new Uri(Url), ClientId, Tenant, PEMCertificate, PEMPrivateKey, CertificatePassword, MinimalHealthScore, RetryCount, RetryWait, RequestTimeout, TenantAdminUrl, Host, NoTelemetry, SkipTenantAdminCheck, AzureEnvironment);
#endif
#else
return null;
Expand All @@ -1053,7 +1057,7 @@ private PnPConnection ConnectAppOnlyAadThumb()
#if !NETSTANDARD2_1
return PnPConnectionHelper.InitiateAzureADAppOnlyConnection(new Uri(Url), ClientId, Tenant, Thumbprint, MinimalHealthScore, RetryCount, RetryWait, RequestTimeout, TenantAdminUrl, Host, NoTelemetry, SkipTenantAdminCheck, AzureEnvironment);
#else
throw new NotImplementedException();
return PnPConnectionHelper.InitiateAzureADAppOnlyConnection(new Uri(Url), ClientId, Tenant, Thumbprint, MinimalHealthScore, RetryCount, RetryWait, RequestTimeout, TenantAdminUrl, Host, NoTelemetry, SkipTenantAdminCheck, AzureEnvironment);
#endif
#else
return null;
Expand Down Expand Up @@ -1296,6 +1300,7 @@ private PnPConnection ConnectWebLogin()
return PnPConnectionHelper.InstantiateWebloginConnection(new Uri(Url), MinimalHealthScore, RetryCount, RetryWait, RequestTimeout, TenantAdminUrl, Host, SkipTenantAdminCheck);
#else
WriteWarning(@"-UseWebLogin is not implemented, due to restrictions of the .NET Standard framework. Use -PnPO365ManagementShell instead");
return null;
#endif
}

Expand All @@ -1321,6 +1326,7 @@ private PnPConnection ConnectCredentials(PSCredential credentials)
}
}

#if !NETSTANDARD2_1
return PnPConnectionHelper.InstantiateSPOnlineConnection(new Uri(Url),
credentials,
Host,
Expand All @@ -1333,11 +1339,24 @@ private PnPConnection ConnectCredentials(PSCredential credentials)
NoTelemetry,
SkipTenantAdminCheck,
AuthenticationMode);
#else
return PnPConnectionHelper.InstantiateSPOnlineConnection(new Uri(Url),
credentials,
Host,
CurrentCredentials,
MinimalHealthScore,
RetryCount,
RetryWait,
RequestTimeout,
TenantAdminUrl,
NoTelemetry,
SkipTenantAdminCheck);
#endif
}

#endregion
#endregion

#region Helper methods
#region Helper methods
private PSCredential GetCredentials()
{
var connectionUri = new Uri(Url);
Expand Down Expand Up @@ -1410,6 +1429,6 @@ private void WriteUpdateMessage(string message)
WriteWarning(message);
}
}
#endregion
#endregion
}
}
2 changes: 1 addition & 1 deletion Commands/Base/GetStoredCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected override void ProcessRecord()
var creds = Utilities.CredentialManager.GetCredential(Name);
if(creds != null)
{
var spoCreds = new Microsoft.SharePoint.Client.SharePointOnlineCredentials(creds.UserName, creds.Password);
var spoCreds = new System.Net.NetworkCredential(creds.UserName, creds.Password);
WriteObject(spoCreds);
} else
{
Expand Down
2 changes: 1 addition & 1 deletion Commands/Base/InitializePowerShellAuthentication.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if !ONPREMISES
#if !ONPREMISES && !NETSTANDARD2_1
using Newtonsoft.Json;
using OfficeDevPnP.Core.Utilities;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
Expand Down
4 changes: 3 additions & 1 deletion Commands/Base/InvokeSPRestMethod.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.SharePoint.Client;
#if !NETSTANDARD2_1
using Microsoft.SharePoint.Client;
using Newtonsoft.Json;
using OfficeDevPnP.Core.Utilities;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
Expand Down Expand Up @@ -233,3 +234,4 @@ public static extern bool InternetGetCookieEx(
}
}
}
#endif
6 changes: 4 additions & 2 deletions Commands/Base/PnPConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,10 @@ internal ClientContext CloneContext(string url)
if ((ex is WebException || ex is NotSupportedException) && CurrentConnection.PSCredential != null)
{
// legacy auth?
var authManager = new OfficeDevPnP.Core.AuthenticationManager();
context = authManager.GetAzureADCredentialsContext(url.ToString(), CurrentConnection.PSCredential.UserName, CurrentConnection.PSCredential.Password);
using(var authManager = new OfficeDevPnP.Core.AuthenticationManager())
{
context = authManager.GetAzureADCredentialsContext(url.ToString(), CurrentConnection.PSCredential.UserName, CurrentConnection.PSCredential.Password);
}
context.ExecuteQueryRetry();
}
else
Expand Down
Loading

0 comments on commit b812c37

Please sign in to comment.