Hello again,
I finaly managed to reuse my "mgm_cli" session in order to sucessfully run my "Access Role" query and to find the time to report back here. (only used on MDM/DMS (a specific domain))
Thanks to all that helped me figuring out the commands needed.
What I wanted to achieve:
- To get a list of all the Access Roles created on the Management Server
- To get the "MS Active Directory (AD)"-groups contained within these Access Roles
- Later I needed to be able to accociate the AD-groups to the Access Roles
The Background:
- Migration of AD-entries to a different Active Directory. Which ones are used in the firewall rules and mapping of the existing ones to the according Access Role where they can be found to be replaced
What I needed to do (tested on MDM only):
- Get the domain "objid" (required on MDM)
- Login to the mgmt_cli and reuse this session for further commands to be copy/pasted for prozessing
- Generate a list of Access Roles (AR)
- Use the list of AR to genrate one list of AD-groups used in all ARs
- Compose an Excel file where each AD-group has a corresponding AR in the adjacent cell, so both columns can be searched.
The commands:
- Get the Domain "objid"(MDM)
psql_client cpm postgres -c"select objid,name from domainbase_data where dlesession=0 and not deleted;"
- Log in to the Domain with the "objid" identified before (MDM)
mgmt_cli login -d 78sd67ff4-2114-4542-821e-e3ed48f7e102 -u <user> -p <password> > /var/log/tmp/sid.txt.$$
<user> = you need to replace this with the account name of the user required to authenticate
<password> = you need to replace this with the according password of the account specified in "-u"
- Generate the ist of ARs, reusing the login session from above
mgmt_cli -s /var/log/tmp/sid.txt.$$ show access-roles limit 500 offset 0 --format json | $CPDIR/jq/jq -r .objects[].name > /var/log/tmp/ARs.txt
mgmt_cli -s /var/log/tmp/sid.txt.$$ show access-roles limit 500 offset 500 --format json | $CPDIR/jq/jq -r .objects[].name >> /var/log/tmp/ARs.txt
mgmt_cli -s /var/log/tmp/sid.txt.$$ show access-roles limit 500 offset 1000 --format json | $CPDIR/jq/jq -r .objects[].name >> /var/log/tmp/ARs.txt
mgmt_cli -s /var/log/tmp/sid.txt.$$ show access-roles limit 500 offset 1500 --format json | $CPDIR/jq/jq -r .objects[].name >> /var/log/tmp/ARs.tx
These are 4 separate commands. You need more if your list of Access Roles is longer than 1500!
There is a hard limit of a maximum of 500 entries when using "show access-roles". Default is 50. This requires the use of the parameters "limit" (amount of AR entries) and "offset" (where to start counting in the list of AR entries). Funny enough stopping (limit) at 500 and starting (offset) at 500 in the next command does not cause a duplicate entry to output!
- Generate the list of AD-groups, reusing the login session from above once again
(for i in $(< /var/log/tmp/ARs.txt) ; do echo \# $i\;$(mgmt_cli -s /var/log/tmp/sid.txt.$$ show access-role name "$i" --format json | $CPDIR/jq/jq -r .users[].name | awk '{print $0 "\r"}' | sed 's/ //g') ; done) > /var/log/tmp/AD-groups.txt
The output is a list like the following, I am able to finalize in Excel to my needs (because I am not that good at text editing with linux). Maybe I'll get some help for that and optimize it, so it does not require so much work in Excel as it does now:
# G_SharedServices;ad_group_G_SharedServices
# G_Developer_ALL;ad_group_G_T_LI_Developer
ad_group_G_T_CD_Developer
ad_group_G_T_DSRF_Developer
ad_group_G_T_AOUTO_Developer
ad_group_G_T_CC_Developer
...snip...
ad_group_G_JKSD_Dev_Tst
ad_group_G_RCRM_Developer
ad_group_G_CDE_BSC_Fortz_Developer
ad_group_G_SME_Dev_Tst
ad_group_G_POP_DevTest
ad_group_G_OCC_CS_Developer
# G_MaltedBausda;ad_group_G_MaltedBausda
# G_MaltedBausda_QA;ad_group_G_MaltedBausda_QA
- "# " I added to differenciate the name of th AR in the list from the AD-Groups more easily (I remove it in Excel later).
- ";" was simple enough for me to add, that made it easier to import the text to excel and immediately split into two columns using this as a seperator for ARs and containing AD-groups
- "ad_group_", "ad_user_" and "ad_branch_" I have to remove or transform in to a category in Excel for now
This is something I can work with easily enough for now. Feel free to improve the output especially in the 4th command. Or the number of commands needed in 3rd step overcomming the limit of 500 entries being output at once.
I hope this helps other people in dire need 😉
Best regards
Carsten
PS.: Some "invalid HTML has been removed", I checked but could not find the location of the "removal" and also did not see the commands being broken. Let me know if you find an error, so I can fix it.