-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathldapGetMaxIds
executable file
·78 lines (62 loc) · 2.37 KB
/
ldapGetMaxIds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /usr/bin/python
import sys
import ldap
from ldapConf import *
from optparse import OptionParser
from ldapConf import *
from ldapUtil import *
####################################################################################
# global constants
####################################################################################
version="%prog: v0.82 (2011-Nov-27)"
modifiedBy="Garry Thuna"
###################################################################################
# parse command line options
###################################################################################
usage = "usage: %prog [options]"
description = "Find the maximum uidNumber and gidNumber used under " + BASE_DN
parser = OptionParser(usage=usage, version=version, description=description)
(options, args) = parser.parse_args()
####################################################################################
# bind to the ldap server
# do the preliminary procssing of users and groups
# do the preliminary procssing of workspaces
####################################################################################
con = ldap.initialize(BIND_URI)
con.start_tls_s()
con.simple_bind_s(BIND_DN, BIND_PW)
groups, \
users, \
gnum2idx, \
gid2idx, \
uid2idx, \
belongsTo, \
workspaces, \
awsName2ws, \
awsName2path, \
gnum2awsName, \
servers, \
asName2server = preProcessLdapObjects(con)
con.unbind_s()
####################################################################################
# calc the maximums
####################################################################################
print '==============================================================='
print '= Maximum ID Numbers ='
print '==============================================================='
maxUidNumber = 0
maxUidNumberDN = ''
for u in users:
cur = int(u[1]['uidNumber'][0])
if cur > maxUidNumber:
maxUidNumber = cur
maxUidNumberDN = u[0]
maxGidNumber = 0
maxGidNumberDN = ''
for g in groups:
cur = int(g[1]['gidNumber'][0])
if cur > maxGidNumber:
maxGidNumber = cur
maxGidNumberDN = g[0]
print "max uidNumber: ", maxUidNumber, maxUidNumberDN
print "max gidNumber: ", maxGidNumber, maxGidNumberDN