1313using System . Security . Cryptography . X509Certificates ;
1414using System . IdentityModel . Tokens . Jwt ;
1515using SharePointPnP . PowerShell . Commands . Enums ;
16+ #if ! NETSTANDARD2_1
1617using System . Web . UI . WebControls ;
18+ #endif
1719using SharePointPnP . PowerShell . Commands . Model ;
1820using Resources = SharePointPnP . PowerShell . Commands . Properties . Resources ;
21+ #if ! NETSTANDARD2_1
1922using System . Security . Cryptography ;
23+ #endif
2024using System . Reflection ;
21- #if NETSTANDARD2_1
22- using System . IdentityModel . Tokens . Jwt ;
23- #endif
2425#if ! ONPREMISES
2526#endif
2627
@@ -375,8 +376,10 @@ public class ConnectOnline : BasePSCmdlet
375376 [ 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." ) ]
376377 public SwitchParameter UseWebLogin ;
377378
379+ #if ! NETSTANDARD2_1
378380 [ Parameter ( Mandatory = false , ParameterSetName = ParameterSet_MAIN , HelpMessage = "Specify to use for instance use forms based authentication (FBA)" ) ]
379381 public ClientAuthenticationMode AuthenticationMode = ClientAuthenticationMode . Default ;
382+ #endif
380383
381384 [ Parameter ( Mandatory = false , ParameterSetName = ParameterSet_MAIN , HelpMessage = "If you want to create a PSDrive connected to the URL" ) ]
382385 [ Parameter ( Mandatory = false , ParameterSetName = ParameterSet_TOKEN , HelpMessage = "If you want to create a PSDrive connected to the URL" ) ]
@@ -693,10 +696,11 @@ protected void Connect()
693696 connection = ConnectAppOnlyAadCer ( ) ;
694697 break ;
695698
699+ #if ! NETSTANDARD2_1
696700 case ParameterSet_GRAPHWITHSCOPE :
697701 connection = ConnectGraphWithScope ( ) ;
698702 break ;
699-
703+ #endif
700704 case ParameterSet_ACCESSTOKEN :
701705 connection = ConnectAccessToken ( ) ;
702706 break ;
@@ -782,7 +786,7 @@ protected void Connect()
782786 }
783787 }
784788
785- #region Connect Types
789+ #region Connect Types
786790
787791 /// <summary>
788792 /// Connect using the paramater set TOKEN
@@ -1036,7 +1040,7 @@ private PnPConnection ConnectAppOnlyAadPem()
10361040#if ! NETSTANDARD2_1
10371041 return PnPConnectionHelper . InitiateAzureADAppOnlyConnection ( new Uri ( Url ) , ClientId , Tenant , PEMCertificate , PEMPrivateKey , CertificatePassword , MinimalHealthScore , RetryCount , RetryWait , RequestTimeout , TenantAdminUrl , Host , NoTelemetry , SkipTenantAdminCheck , AzureEnvironment ) ;
10381042#else
1039- throw new NotImplementedException ( ) ;
1043+ return PnPConnectionHelper . InitiateAzureADAppOnlyConnection ( new Uri ( Url ) , ClientId , Tenant , PEMCertificate , PEMPrivateKey , CertificatePassword , MinimalHealthScore , RetryCount , RetryWait , RequestTimeout , TenantAdminUrl , Host , NoTelemetry , SkipTenantAdminCheck , AzureEnvironment ) ;
10401044#endif
10411045#else
10421046 return null ;
@@ -1053,7 +1057,7 @@ private PnPConnection ConnectAppOnlyAadThumb()
10531057#if ! NETSTANDARD2_1
10541058 return PnPConnectionHelper . InitiateAzureADAppOnlyConnection ( new Uri ( Url ) , ClientId , Tenant , Thumbprint , MinimalHealthScore , RetryCount , RetryWait , RequestTimeout , TenantAdminUrl , Host , NoTelemetry , SkipTenantAdminCheck , AzureEnvironment ) ;
10551059#else
1056- throw new NotImplementedException ( ) ;
1060+ return PnPConnectionHelper . InitiateAzureADAppOnlyConnection ( new Uri ( Url ) , ClientId , Tenant , Thumbprint , MinimalHealthScore , RetryCount , RetryWait , RequestTimeout , TenantAdminUrl , Host , NoTelemetry , SkipTenantAdminCheck , AzureEnvironment ) ;
10571061#endif
10581062#else
10591063 return null ;
@@ -1296,6 +1300,7 @@ private PnPConnection ConnectWebLogin()
12961300 return PnPConnectionHelper . InstantiateWebloginConnection ( new Uri ( Url ) , MinimalHealthScore , RetryCount , RetryWait , RequestTimeout , TenantAdminUrl , Host , SkipTenantAdminCheck ) ;
12971301#else
12981302 WriteWarning ( @"-UseWebLogin is not implemented, due to restrictions of the .NET Standard framework. Use -PnPO365ManagementShell instead" ) ;
1303+ return null ;
12991304#endif
13001305 }
13011306
@@ -1321,6 +1326,7 @@ private PnPConnection ConnectCredentials(PSCredential credentials)
13211326 }
13221327 }
13231328
1329+ #if ! NETSTANDARD2_1
13241330 return PnPConnectionHelper . InstantiateSPOnlineConnection ( new Uri ( Url ) ,
13251331 credentials ,
13261332 Host ,
@@ -1333,11 +1339,24 @@ private PnPConnection ConnectCredentials(PSCredential credentials)
13331339 NoTelemetry ,
13341340 SkipTenantAdminCheck ,
13351341 AuthenticationMode ) ;
1342+ #else
1343+ return PnPConnectionHelper . InstantiateSPOnlineConnection ( new Uri ( Url ) ,
1344+ credentials ,
1345+ Host ,
1346+ CurrentCredentials ,
1347+ MinimalHealthScore ,
1348+ RetryCount ,
1349+ RetryWait ,
1350+ RequestTimeout ,
1351+ TenantAdminUrl ,
1352+ NoTelemetry ,
1353+ SkipTenantAdminCheck ) ;
1354+ #endif
13361355 }
13371356
1338- #endregion
1357+ #endregion
13391358
1340- #region Helper methods
1359+ #region Helper methods
13411360 private PSCredential GetCredentials ( )
13421361 {
13431362 var connectionUri = new Uri ( Url ) ;
@@ -1410,6 +1429,6 @@ private void WriteUpdateMessage(string message)
14101429 WriteWarning ( message ) ;
14111430 }
14121431 }
1413- #endregion
1432+ #endregion
14141433 }
14151434}
0 commit comments