Skip to content

Instantly share code, notes, and snippets.

@sochotnicky
Created July 25, 2017 11:57
Show Gist options
  • Save sochotnicky/85ed577751dcf9063befa20fdee2a8ca to your computer and use it in GitHub Desktop.
Save sochotnicky/85ed577751dcf9063befa20fdee2a8ca to your computer and use it in GitHub Desktop.
/home/w0rm/bin/hire_dates.py
import sys
import ldap
l = ldap.initialize('ldap://ldap.corp.redhat.com')
groups = l.search_s('dc=redhat,dc=com', ldap.SCOPE_SUBTREE,
'cn=%s' % sys.argv[1])
for group in groups:
query = '(|(uid=%s))' % ')(uid='.join(group[1]['memberUid'])
users = l.search_s('dc=redhat,dc=com', ldap.SCOPE_SUBTREE,
query)
for cn, user in users:
if 'rhatHireDate' in user:
for hired in user['rhatHireDate']:
print user['uid'][0], hired
else:
print "No hire date for %s" % user['uid'][0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment