Fetch role information of a Perforce branch using P4.Net DLL - p4.net

I want to fetch role (AD Group) information of a P4 branch using P4.Net. Is there a way to find which AD Group has access to a perticular P4 branch.

P4 Protects command can be used to get role information.
Syntax:
p4 protects [folder/file path]
Above command gives list of all the groups\users who are having access to the p4 folder\file

Related

Azure Resource/Resource Groups using AD Groups

We are trying to find a way to fetch the list of resources to which the AD Groups are mapped to. We have a huge list of AD groups (17k+ AD groups) and we have to update the tags of the resources to which the AD Groups belong to. We have a script to bulk update tags of the resources but we don't have the resource list for these specific resources.
• As you are confirming that each resource that you have created in Azure has been assigned a tag of the Azure AD group that it is mapped to, then it is quite aptly possible to get the list of resources for which a particular group is mentioned as a tag in it. For that purpose, kindly execute the below powershell command with atleast ‘Contributor’ role Azure assignment to the ID through which this command will be executed.
To get the list of Azure resources tagged with the exact value as ‘Reason’ as ‘Repro’, use the command below: -
(Get-AzResource -Tag #{ “Reason"="Repro"}).Name
Output: -
Similarly, if you want the list of resource groups that have a tag value of 'Reason : Repro' with the exact name and value, kindly use the below powershell command: -
(Get-AzResourceGroup -Tag #{ "Reason"="Repro" }).ResourceGroupName
Output: -
To know more about the commands relating to the above, kindly refer to the below documentation link: -
https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources?tabs=json#list-by-tag

How can I get the name of a role with the role's ID in Discord.py?

So, I am making a command that allows the users in my server to create aesthetic-only roles, and I already have a command to create them (they can only specify the colour and the name) and to add/remove them. However, I still want to add a feature, which searches all roles in the server if a role with the same name already exists when it is created. I found this code from another question to list all the roles in the server (and I honestly do not understand a bit what is happening in that line but it works):
rolelist = (", ".join([str(r.id) for r in ctx.guild.roles]))
This code unfortunately only returns the IDs of the roles and I can not find a way to convert the IDs into the names of the roles so that I can actually use it to check if the role created already exist. I tried adding ".name" to the end of "ctx.guild.roles" but that did not work and returned this error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'list' object has no attribute 'name'
To summarize, I need a way to put in a string of integers taken from the previously mentioned "rolelist" variable and turn them into the names of the roles. Any help is greatly appreciated and I thank you in advance.
You can use discord.utils.get() function. It returns None if an object with specified attributes not found.
See an example below:
#bot.command()
async def check_role(ctx, *, name: str):
await ctx.send("Role with specified name found." if discord.utils.get(ctx.guild.roles, name=name) is None else "Role with specified name not found.")
If you know role ID you can do something like this:
role_id = 12345
role = guild.get_role(role_id) # get the role
print(role.name) # print role name

Privileged access groups

Anyone have any clues how to manage eligible assignments in privileged access enabled groups with PowerShell?
Get-AzureADMSGroup shows the group IsAssignableToRole is True and Get-AzureADGroupMember shows no members as they're not directly assigned.
The AzureAdPreview module has a number of commands to manage PIM roles. https://learn.microsoft.com/en-us/powershell/module/azuread/?view=azureadps-2.0-preview#privileged-role-management
But with privileged access groups, I can't work out the commands to assign eligible user assignments to a group rather than to a role.
Hi Can you please try the below Command to add the user to your required group --
Add-ADGroupMember -Identity Groupname -Members user1,user2
Groupname - Please mention the name of group.
User1 - 1st user ;
User2 - 2nd User
Please have a look this Document if it helps you.
Thank You.

How to change computer's canonical/displayed name in Active Directory?

I have an AD with 71 computers.
However, there are actually less than 50 physical computers, so I'm doing some cleanup. But, up until now when renaming PC's, I've only renamed them at the workstation through Control Panel->System.
So, the displayed name of computers in AD does not match the workstation's computer name. The displayed name, the "Canonical name of object" under Properties->Object, and the cn attribute in Attribute Editor are all the old name, while the "Computer name" and "DNS name" under Properties->General are the updated name also found at the workstation.
How do I reconcile the two different sets of names for each computer? I cannot edit the "Canonical name of object" in Properties, nor can I edit the cn attribute:
Operation failed. Error code: 0x2016; The directory service cannot
perform the requested operation on the RDN attribute of an object.
00002016: Modify of RDN 'CN' on CN=COMP,OU=TEST,DC=DOMAIN,DC=local not
permitted, must use 'rename operation instead.
Going forward, what is the proper way to rename a PC so that it updates both at the workstation and throughout AD?
There is a command line available (reference here: https://technet.microsoft.com/en-us/library/cc788029.aspx) that people will use to automate the renaming of domain-joined workstations.
It's a two-step process: first you rename the computer, and then rename its OU/CN. netdom renamecomputer doesn't rename the AD object, and I assume that Rename-Computer doesn't either (please edit this answer if that's incorrect).
PowerShell
Rename-Computer
[ Get-ADComputer | ] Rename-ADObject
CMD
netdom renamecomputer
dsmove

Drupal 7: Using Rules to add user to OG then assign OG role

The idea is to accomplish the following when a new user is added:
Create a new group (OG)
Save it
Add user to saved group (OG)
Assign group role (OG)
I am using Rules with Organic Groups. All is fine apart from assigning the group role. I know you can add general system roles but does anyone know how to assign a group (OG) role programmaticaly so it happens automagically?
Any help much appreciated
I use the following custom php action on a rule, to add user to group and assign OG role.
OG role numbers appear to be in order of OG roles, as viewed through admin/config OG entries.
global $user;
// Load the user we want to add to the group
$account = user_load($user->uid);
// Add the user to the group - hard code group 18 which is my group as cant
// get PID from Ubercart order, to pull gid from nid. User, current user, active,
// etc., all default in 2nd array() param to og_group.
og_group(18);
// Changes the users role in the group (1 = non-member, 2 = member, 3 = administrator member, 4 = Forum Administrator)
og_role_grant(18, $account->uid, 2);
Note, OG role 4 (forum administrator) is a custom OG role I created. Also, 'member' (2) is the default, I believe, but I put this in so I'd remember how to allocate other OG roles if I needed to in future.
I'm not a php guru unfortunately, and I still havent worked out how to pull the pid from the node of the Ubercart product ordered so I can get its gid and hence not hard code the gid of 18.
Hope the above code snipped (og_role_grant mainly) works for you as a rule action custom php code snippet (remember not to include the php tags at top and bottom as rules does this for you).
If you have any thoughts on my problem of getting the gid of the ordered ubercart product, as above, please feel free to share. :)
Best wishes
There is a proposed Organic Group patch that add this functionality to the Organic Group Rules integration.
You can find the patch here: https://drupal.org/node/1327326
It adds Grant and Revoke role actions.
You can use og_role_grant($group_type, $gid, $uid, $rid) to assign a role to a user into an organic group programmatically.
To use this with rules, you can define a custom action using hook_rules_action_info() .

Resources