Skip to content

Instantly share code, notes, and snippets.

@dkavanagh
Last active April 7, 2024 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkavanagh/2d8efa70e4c9351eb55ce10f122af80e to your computer and use it in GitHub Desktop.
Save dkavanagh/2d8efa70e4c9351eb55ce10f122af80e to your computer and use it in GitHub Desktop.
#!/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