Created
July 25, 2017 11:57
-
-
Save sochotnicky/85ed577751dcf9063befa20fdee2a8ca to your computer and use it in GitHub Desktop.
/home/w0rm/bin/hire_dates.py
This file contains 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
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