How-To: List users by creation date

You can list all users sorted by creation date with the following bash script

#!/usr/bin/env bash
univention-ldapsearch -LLLo ldif-wrap=no \
  "(&(!(sn=None))(!(objectClass=simpleSecurityObject))(objectClass=organizationalPerson))" \
  cn uid gidNumber createTimestamp

or with a group lookup via python

#!/usr/bin/env python
import univention.admin.uldap
lo = univention.uldap.getMachineConnection()
results = lo.search('(&(!(sn=None))(!(objectClass=simpleSecurityObject))(objectClass=organizationalPerson))', attr=["cn", "uid", "gidNumber", "createTimestamp"])
for (dn, attrs) in results:
    (grpDn, grpAttrs) = lo.search('(&(gidNumber={0})(objectClass=univentionGroup))'.format(attrs['gidNumber'][0]))[0]
    print("DN: {0}\n\tname:\t {1[cn][0]}\n\tuid:\t {1[uid]}\n\tgroup:\t {1[gidNumber]} {2[cn]}\n\tcreated: {1[createTimestamp][0]}\n".format(dn, attrs, grpAttrs))
Mastodon