This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1604 from SharePoint/dev
June 2018 Release
- Loading branch information
Showing
18 changed files
with
330 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,10 @@ | |
namespace SharePointPnP.PowerShell.Commands.Admin | ||
{ | ||
[Cmdlet(VerbsSecurity.Grant, "PnPHubSiteRights")] | ||
[CmdletHelp(@"Retrieve all or a specific hubsite.", | ||
[CmdletHelp(@"Grant Permissions to associate sites to Hub Sites.", | ||
Category = CmdletHelpCategory.TenantAdmin, | ||
SupportedPlatform = CmdletSupportedPlatform.Online)] | ||
[CmdletExample(Code = @"PS:> Get-PnPStorageEntity", Remarks = "Returns all site storage entities/farm properties", SortOrder = 1)] | ||
[CmdletExample(Code = @"PS:> Get-PnPTenantSite -Key MyKey", Remarks = "Returns the storage entity/farm property with the given key.", SortOrder = 2)] | ||
[CmdletExample(Code = @"PS:> Grant-PnPHubSiteRights -Identity https://contoso.sharepoint.com/sites/hubsite -Principals ""[email protected]"",""[email protected]"" -Rights Join", Remarks = "This example shows how to grant right to myuser and myotheruser to associate their sites with hubsite", SortOrder = 1)] | ||
public class GrantHubSiteRights : PnPAdminCmdlet | ||
{ | ||
[Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true)] | ||
|
@@ -34,4 +33,4 @@ protected override void ExecuteCmdlet() | |
} | ||
} | ||
} | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#if !ONPREMISES | ||
using Microsoft.Online.SharePoint.TenantAdministration.Internal; | ||
using Microsoft.SharePoint.Client; | ||
using OfficeDevPnP.Core.ALM; | ||
using OfficeDevPnP.Core.Enums; | ||
using SharePointPnP.PowerShell.CmdletHelpAttributes; | ||
using SharePointPnP.PowerShell.Commands.Base; | ||
using SharePointPnP.PowerShell.Commands.Enums; | ||
using SharePointPnP.PowerShell.Commands.Model; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
|
||
namespace SharePointPnP.PowerShell.Commands.Apps | ||
{ | ||
[Cmdlet(VerbsSecurity.Grant, "PnPTenantServicePrincipalPermission")] | ||
[CmdletHelp(@"Explicitely grants a specified permission to the ""SharePoint Online Client"" service principal", | ||
Category = CmdletHelpCategory.Apps, SupportedPlatform = CmdletSupportedPlatform.Online, | ||
OutputType = typeof(AppMetadata))] | ||
[CmdletExample( | ||
Code = @"PS:> Grant-PnPTenantServicePrincipalPermission -Scope ""Group.Read.All"" -Resource ""Microsoft Graph""", | ||
Remarks = @"This will explicitely grant the Group.Read.All permission on the Microsoft Graph resource", SortOrder = 1)] | ||
public class GrantTenantServicePrincipalPermission : PnPAdminCmdlet | ||
{ | ||
[Parameter(Mandatory = true, HelpMessage = "The scope to grant the permission for")] | ||
public string Scope; | ||
|
||
[Parameter(Mandatory = true, HelpMessage = "The resource to grant the permission for")] | ||
public string Resource; | ||
|
||
protected override void ExecuteCmdlet() | ||
{ | ||
var packageName = $"pnp-temporary-request-{System.Guid.NewGuid()}"; | ||
var appCatalog = Tenant.GetAppCatalog(); | ||
using (var appCatalogContext = ClientContext.Clone(appCatalog)) | ||
{ | ||
var list = appCatalogContext.Web.Lists.GetByTitle("Web Api Permission Requests"); | ||
var itemCI = new ListItemCreationInformation(); | ||
var item = list.AddItem(itemCI); | ||
item["_ows_PackageName"] = packageName; | ||
item["_ows_PackageVersion"] = "0.0.0.0"; | ||
item["_ows_Scope"] = Scope; | ||
item["_ows_ResourceId"] = Resource; | ||
item.Update(); | ||
appCatalogContext.ExecuteQueryRetry(); | ||
} | ||
|
||
var servicePrincipal = new SPOWebAppServicePrincipal(ClientContext); | ||
var requests = ClientContext.LoadQuery(servicePrincipal.PermissionRequests.Where(r => r.PackageName == packageName)); | ||
ClientContext.ExecuteQueryRetry(); | ||
if (requests.Any()) | ||
{ | ||
var newRequest = requests.First(); | ||
var request = servicePrincipal.PermissionRequests.GetById(newRequest.Id); | ||
var grant = request.Approve(); | ||
ClientContext.Load(grant); | ||
ClientContext.ExecuteQueryRetry(); | ||
WriteObject(new TenantServicePrincipalPermissionGrant(grant)); | ||
} | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.