Last active
April 7, 2024 17:35
-
-
Save dkavanagh/2d8efa70e4c9351eb55ce10f122af80e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
''' First, use https://api-ipv4.us-or.viasat.io/Users.html#list-users to download | |
user data to a file called users.json. | |
''' | |
import argparse | |
import json | |
def main(): | |
''' Do the things | |
''' | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--stripe', | |
help='Stripe name', | |
type=str, | |
required=True) | |
parser.add_argument('--group', | |
help='Group name', | |
type=str, | |
required=True) | |
opts = parser.parse_args() | |
with open('users.json', encoding='utf-8') as users: | |
users = json.loads(users.read()) | |
group_dn = f'cn={opts.group},ou=Groups,ou={opts.stripe},ou=Environments,dc=viasat,dc=io' | |
for user in users: | |
if group_dn in user.get('memberOfDnList') and user.get('lockType')!='admin': | |
print(user.get('email')) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment