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

Commit

Permalink
v2.2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AMSoftwareNL committed Nov 7, 2021
1 parent 4e09f80 commit ab06985
Show file tree
Hide file tree
Showing 100 changed files with 3,869 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,52 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Security\GetPrincipalPrivilegesCommand.cs" />
<Compile Include="Content\GetContentAccessCommand.cs" />
<Compile Include="Security\GetTeamTemplateCommand.cs" />
<Compile Include="Security\TestUserPrivilegeCommand.cs" />
<Compile Include="Security\GetRolePrivilegesCommand.cs" />
<Compile Include="Security\RemoveRecordTeamUserCommand.cs" />
<Compile Include="Security\AddRecordTeamUserCommand.cs" />
<Compile Include="Security\RemoveRolePrivilegeCommand.cs" />
<Compile Include="Security\RemoveTeamTemplateCommand.cs" />
<Compile Include="Security\RemoveTeamCommand.cs" />
<Compile Include="Security\SetRolePrivilegeCommand.cs" />
<Compile Include="Security\SetTeamTemplateCommand.cs" />
<Compile Include="Security\NewTeamTemplateCommand.cs" />
<Compile Include="Administration\GetEnvironmentVariableCommand.cs" />
<Compile Include="Administration\GetSPDocucmentLocationCommand.cs" />
<Compile Include="Administration\InvokeWebApiRequestCommand.cs" />
<Compile Include="Security\SetRoleCommand.cs" />
<Compile Include="Security\NewApplicationCommand.cs" />
<Compile Include="Security\SetTeamCommand.cs" />
<Compile Include="Administration\SetEnvironmentVariableCommand.cs" />
<Compile Include="Administration\NewEnvironmentVariableCommand.cs" />
<Compile Include="Administration\NewTeamCommand.cs" />
<Compile Include="Security\NewTeamCommand.cs" />
<Compile Include="Administration\NewBusinessUnitCommand.cs" />
<Compile Include="Administration\NewRoleCommand.cs" />
<Compile Include="Administration\GetTeamUsersCommand.cs" />
<Compile Include="Administration\GetRolePrincipalsCommand.cs" />
<Compile Include="Administration\GetTeamCommand.cs" />
<Compile Include="Security\NewRoleCommand.cs" />
<Compile Include="Security\GetTeamUsersCommand.cs" />
<Compile Include="Security\GetRolePrincipalsCommand.cs" />
<Compile Include="Security\GetTeamCommand.cs" />
<Compile Include="Administration\GetBusinessUnitCommand.cs" />
<Compile Include="Administration\GetRoleCommand.cs" />
<Compile Include="Administration\GetUserTeamsCommand.cs" />
<Compile Include="Administration\GetPrincipalRolesCommand.cs" />
<Compile Include="Administration\RemoveUserParentCommand.cs" />
<Compile Include="Security\GetRoleCommand.cs" />
<Compile Include="Security\GetUserTeamsCommand.cs" />
<Compile Include="Security\GetPrincipalRolesCommand.cs" />
<Compile Include="Security\RemoveUserParentCommand.cs" />
<Compile Include="Administration\RemoveEnvironmentVariableCommand.cs" />
<Compile Include="Administration\SetOwnerCommand.cs" />
<Compile Include="Administration\RemovePrincipalRolesCommand.cs" />
<Compile Include="Administration\RemoveRolePrincipalsCommand.cs" />
<Compile Include="Administration\RemoveTeamUsersCommand.cs" />
<Compile Include="Administration\SetTeamUsersCommand.cs" />
<Compile Include="Administration\SetRolePrincipalsCommand.cs" />
<Compile Include="Administration\RemoveUserTeamsCommand.cs" />
<Compile Include="Administration\SetUserTeamsCommand.cs" />
<Compile Include="Administration\SetPrincipalRolesCommand.cs" />
<Compile Include="Administration\NewUserCommand.cs">
<Compile Include="Security\SetOwnerCommand.cs" />
<Compile Include="Security\RemovePrincipalRolesCommand.cs" />
<Compile Include="Security\RemoveRolePrincipalsCommand.cs" />
<Compile Include="Security\RemoveTeamUsersCommand.cs" />
<Compile Include="Security\SetTeamUsersCommand.cs" />
<Compile Include="Security\SetRolePrincipalsCommand.cs" />
<Compile Include="Security\RemoveUserTeamsCommand.cs" />
<Compile Include="Security\SetUserTeamsCommand.cs" />
<Compile Include="Security\SetPrincipalRolesCommand.cs" />
<Compile Include="Security\NewUserCommand.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Administration\GetUserCommand.cs" />
<Compile Include="Security\GetUserCommand.cs" />
<Compile Include="Administration\RemoveLanguageCommand.cs" />
<Compile Include="Administration\AddLanguageCommand.cs" />
<Compile Include="Administration\GetLanguageCommand.cs" />
Expand Down Expand Up @@ -191,6 +207,7 @@
<Compile Include="Plugins\GetPluginAssemblyCommand.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Customizations\UseSolutionCommand.cs" />
<Compile Include="UseImpersonatedUserCommand.cs" />
<Compile Include="UseLanguageCommand.cs" />
</ItemGroup>
<ItemGroup>
Expand All @@ -206,12 +223,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CrmSdk.XrmTooling.CoreAssembly">
<Version>9.1.0.79</Version>
<Version>9.1.0.92</Version>
</PackageReference>
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies">
<Version>1.1.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(SolutionDir)AMSoftware.Crm.PowerShell\*.*" "$(TargetDir)" /Y
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
CRM PowerShell Library
Copyright (C) 2017 Arjan Meskers / AMSoftware
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using AMSoftware.Crm.PowerShell.Common;
using AMSoftware.Crm.PowerShell.Common.ArgumentCompleters;
using AMSoftware.Crm.PowerShell.Common.Repositories;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk;
using System;
using System.Management.Automation;

namespace AMSoftware.Crm.PowerShell.Commands.Content
{
[Cmdlet(VerbsCommon.Get, "CrmContentAccess", HelpUri = HelpUrlConstants.GetContentAccessHelpUrl, DefaultParameterSetName = GetContentAccessByInputObjectParameterSet)]
[OutputType(typeof(PrincipalAccess))]
public sealed class GetContentAccessCommand : CrmOrganizationCmdlet
{
private const string GetContentAccessParameterSet = "GetContentAccess";
private const string GetContentAccessByInputObjectParameterSet = "GetContentAccessByInputObject";

private readonly ContentRepository _repository = new ContentRepository();

[Parameter(Mandatory = true, Position = 1, ParameterSetName = GetContentAccessByInputObjectParameterSet, ValueFromPipeline = true)]
[Alias("Record")]
[ValidateNotNullOrEmpty]
public Entity InputObject { get; set; }

[Parameter(Mandatory = true, Position = 1, ParameterSetName = GetContentAccessParameterSet)]
[Alias("LogicalName")]
[ArgumentCompleter(typeof(EntityArgumentCompleter))]
[ValidateNotNullOrEmpty]
public string Entity { get; set; }

[Parameter(Mandatory = true, Position = 2, ParameterSetName = GetContentAccessParameterSet)]
[ValidateNotNullOrEmpty]
public Guid Id { get; set; }

protected override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

EntityReference target = null;

switch (this.ParameterSetName)
{
case GetContentAccessParameterSet:
target = new EntityReference(Entity, Id);
break;
case GetContentAccessByInputObjectParameterSet:
target = InputObject.ToEntityReference();
break;
default:
break;
}

OrganizationResponse response = _repository.Execute("RetrieveSharedPrincipalsAndAccess", new System.Collections.Hashtable() {
{ "Target", target }
});

if (response != null && response.Results != null && response.Results.ContainsKey("PrincipalAccesses") && response["PrincipalAccesses"] != null)
{
PrincipalAccess[] principalAccesses = (PrincipalAccess[])response["PrincipalAccesses"];

foreach (var principalAccess in principalAccesses)
{
var o = new PSObject(principalAccess);
o.Properties.Add(new PSNoteProperty("RecordLogicalName", target.LogicalName));
o.Properties.Add(new PSNoteProperty("RecordId", target.Id));
o.Properties.Add(new PSNoteProperty("PrincipalLogicalName", principalAccess.Principal.LogicalName));
o.Properties.Add(new PSNoteProperty("PrincipalId", principalAccess.Principal.Id));
o.Properties.Add(new PSNoteProperty("AccessRight", (CrmAccessRight)principalAccess.AccessMask));

o.Properties.Remove("ExtensionData");
o.Properties.Remove("AccessMask");
o.Properties.Remove("Principal");

WriteObject(o, false);
}
}
}
}
}
Loading

0 comments on commit ab06985

Please sign in to comment.