Forum Discussion
Decode ObjectSID from Base64-encode string
Hi,
I have APM policy that I try to retrieve the user ObjectSID from Active Directory.
The problem is that the APM give this object in Base64-encode string and not in it original format.
Is there any way to decode it in the APM policy or iRule so I’ll get it at the end of the APM policy in it original SID format?
eg
I get it in the policy as AQUAAAAAAAAT1QZ9BTHHd5jj1Isdb88A==
and I want the original SID format, such as S-1-5
Hi MaxMedov, this works local for me, but you might need to flesh out a little functionality to meet your needs. I used bigrest for this sample:
from bigrest.bigip import BIGIP from datetime import datetime datestring = datetime.now().strftime('%Y-%m-%d') hostname = 'ltm3.test.local' br = BIGIP(hostname, 'admin', 'admin', request_token=True) # Save Config data = {'command': 'save'} task = br.task_start("/mgmt/tm/task/sys/config", data) print(f'Task {task.properties["_taskId"]} created at {datetime.now().strftime("%H:%M:%S")}') br.task_wait(task) if br.task_completed(task): br.task_result(task) print(f'Task {task.properties["_taskId"]} completed at {datetime.now().strftime("%H:%M:%S")}') else: raise Exception() # Copy config to /shared/images/ data = {'command': 'run', 'utilCmdArgs': f'-c "cp /config/bigip.conf /shared/images/{datestring}-{hostname}-bigip.conf"'} br.command('/mgmt/tm/util/bash', data) # Save netstat -rn data to /shared/images/ data = {'command': 'run', 'utilCmdArgs': f'-c "netstat -rn > /shared/images/{datestring}-{hostname}-netroute.txt"'} br.command('/mgmt/tm/util/bash', data) # Download files br.download('/mgmt/cm/autodeploy/software-image-downloads/', f'{datestring}-{hostname}-netroute.txt') br.download('/mgmt/cm/autodeploy/software-image-downloads/', f'{datestring}-{hostname}-bigip.conf') # Remove files from /shared/images/ data = {'command': 'run', 'utilCmdArgs': f'/shared/images/{datestring}-{hostname}-netroute.txt'} br.command('/mgmt/tm/util/unix-rm', data) data = {'command': 'run', 'utilCmdArgs': f'/shared/images/{datestring}-{hostname}-bigip.conf'} br.command('/mgmt/tm/util/unix-rm', data)
And after running, I have both files downloaded for me in my local directory:
jrahm@mac scripts % ls -als | grep 2022-09-20 968 -rw-r--r-- 1 rahm 1437522721 495338 Sep 20 01:47 2022-09-20-ltm3.test.local-bigip.conf 8 -rw-r--r-- 1 rahm 1437522721 803 Sep 20 01:47 2022-09-20-ltm3.test.local-netroute.txt
1 Reply
- JRahm
Admin
Hi Sefi_Miz you can use the b64decode command in iRules.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com