13
13
using System . Security . Cryptography . X509Certificates ;
14
14
using System . IdentityModel . Tokens . Jwt ;
15
15
using SharePointPnP . PowerShell . Commands . Enums ;
16
+ #if ! NETSTANDARD2_1
16
17
using System . Web . UI . WebControls ;
18
+ #endif
17
19
using SharePointPnP . PowerShell . Commands . Model ;
18
20
using Resources = SharePointPnP . PowerShell . Commands . Properties . Resources ;
21
+ #if ! NETSTANDARD2_1
19
22
using System . Security . Cryptography ;
23
+ #endif
20
24
using System . Reflection ;
21
- #if NETSTANDARD2_1
22
- using System . IdentityModel . Tokens . Jwt ;
23
- #endif
24
25
#if ! ONPREMISES
25
26
#endif
26
27
@@ -375,8 +376,10 @@ public class ConnectOnline : BasePSCmdlet
375
376
[ 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." ) ]
376
377
public SwitchParameter UseWebLogin ;
377
378
379
+ #if ! NETSTANDARD2_1
378
380
[ Parameter ( Mandatory = false , ParameterSetName = ParameterSet_MAIN , HelpMessage = "Specify to use for instance use forms based authentication (FBA)" ) ]
379
381
public ClientAuthenticationMode AuthenticationMode = ClientAuthenticationMode . Default ;
382
+ #endif
380
383
381
384
[ Parameter ( Mandatory = false , ParameterSetName = ParameterSet_MAIN , HelpMessage = "If you want to create a PSDrive connected to the URL" ) ]
382
385
[ 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()
693
696
connection = ConnectAppOnlyAadCer ( ) ;
694
697
break ;
695
698
699
+ #if ! NETSTANDARD2_1
696
700
case ParameterSet_GRAPHWITHSCOPE :
697
701
connection = ConnectGraphWithScope ( ) ;
698
702
break ;
699
-
703
+ #endif
700
704
case ParameterSet_ACCESSTOKEN :
701
705
connection = ConnectAccessToken ( ) ;
702
706
break ;
@@ -782,7 +786,7 @@ protected void Connect()
782
786
}
783
787
}
784
788
785
- #region Connect Types
789
+ #region Connect Types
786
790
787
791
/// <summary>
788
792
/// Connect using the paramater set TOKEN
@@ -1036,7 +1040,7 @@ private PnPConnection ConnectAppOnlyAadPem()
1036
1040
#if ! NETSTANDARD2_1
1037
1041
return PnPConnectionHelper . InitiateAzureADAppOnlyConnection ( new Uri ( Url ) , ClientId , Tenant , PEMCertificate , PEMPrivateKey , CertificatePassword , MinimalHealthScore , RetryCount , RetryWait , RequestTimeout , TenantAdminUrl , Host , NoTelemetry , SkipTenantAdminCheck , AzureEnvironment ) ;
1038
1042
#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 ) ;
1040
1044
#endif
1041
1045
#else
1042
1046
return null ;
@@ -1053,7 +1057,7 @@ private PnPConnection ConnectAppOnlyAadThumb()
1053
1057
#if ! NETSTANDARD2_1
1054
1058
return PnPConnectionHelper . InitiateAzureADAppOnlyConnection ( new Uri ( Url ) , ClientId , Tenant , Thumbprint , MinimalHealthScore , RetryCount , RetryWait , RequestTimeout , TenantAdminUrl , Host , NoTelemetry , SkipTenantAdminCheck , AzureEnvironment ) ;
1055
1059
#else
1056
- throw new NotImplementedException ( ) ;
1060
+ return PnPConnectionHelper . InitiateAzureADAppOnlyConnection ( new Uri ( Url ) , ClientId , Tenant , Thumbprint , MinimalHealthScore , RetryCount , RetryWait , RequestTimeout , TenantAdminUrl , Host , NoTelemetry , SkipTenantAdminCheck , AzureEnvironment ) ;
1057
1061
#endif
1058
1062
#else
1059
1063
return null ;
@@ -1296,6 +1300,7 @@ private PnPConnection ConnectWebLogin()
1296
1300
return PnPConnectionHelper . InstantiateWebloginConnection ( new Uri ( Url ) , MinimalHealthScore , RetryCount , RetryWait , RequestTimeout , TenantAdminUrl , Host , SkipTenantAdminCheck ) ;
1297
1301
#else
1298
1302
WriteWarning ( @"-UseWebLogin is not implemented, due to restrictions of the .NET Standard framework. Use -PnPO365ManagementShell instead" ) ;
1303
+ return null ;
1299
1304
#endif
1300
1305
}
1301
1306
@@ -1321,6 +1326,7 @@ private PnPConnection ConnectCredentials(PSCredential credentials)
1321
1326
}
1322
1327
}
1323
1328
1329
+ #if ! NETSTANDARD2_1
1324
1330
return PnPConnectionHelper . InstantiateSPOnlineConnection ( new Uri ( Url ) ,
1325
1331
credentials ,
1326
1332
Host ,
@@ -1333,11 +1339,24 @@ private PnPConnection ConnectCredentials(PSCredential credentials)
1333
1339
NoTelemetry ,
1334
1340
SkipTenantAdminCheck ,
1335
1341
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
1336
1355
}
1337
1356
1338
- #endregion
1357
+ #endregion
1339
1358
1340
- #region Helper methods
1359
+ #region Helper methods
1341
1360
private PSCredential GetCredentials ( )
1342
1361
{
1343
1362
var connectionUri = new Uri ( Url ) ;
@@ -1410,6 +1429,6 @@ private void WriteUpdateMessage(string message)
1410
1429
WriteWarning ( message ) ;
1411
1430
}
1412
1431
}
1413
- #endregion
1432
+ #endregion
1414
1433
}
1415
1434
}
0 commit comments