add script to fill ocr config from LDAP (#3455)
This commit is contained in:
parent
ff596fc526
commit
c9e1f58986
|
@ -0,0 +1,43 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
import os
|
||||
import ldap
|
||||
import sys
|
||||
|
||||
ldap_conn = ldap.initialize('ldap://ldap.pcf.be')
|
||||
ldap_conn.simple_bind_s('cn=ldap,ou=ouAdmin,ou=ouUsers,dc=win,dc=info,dc=pcf', sys.argv[1])
|
||||
|
||||
usernames = []
|
||||
|
||||
for entry in ldap_conn.search_s("dc=win,dc=info,dc=pcf", ldap.SCOPE_SUBTREE, "objectclass=user"):
|
||||
if not entry[0]:
|
||||
continue
|
||||
if not entry[1].get('profilePath'):
|
||||
continue
|
||||
|
||||
try:
|
||||
username = entry[1]['sAMAccountName'][0]
|
||||
except KeyError:
|
||||
continue
|
||||
usernames.append(username)
|
||||
|
||||
fd = file('ocrloader-complete.ini', 'w')
|
||||
print >> fd, file('ocrloader.ini').read()
|
||||
|
||||
for username in usernames:
|
||||
print username
|
||||
print >> fd, '''[ged-%(username_lower)s@pfwb.be]
|
||||
default_type = dmsdocument
|
||||
default_directory = Members/%(username)s
|
||||
user = %(username)s
|
||||
|
||||
[ged-file-%(username)s@pfwb.be]
|
||||
store_path = /srv/ocr/%(username)s
|
||||
|
||||
''' % {'username': username, 'username_lower': username.lower()}
|
||||
|
||||
if not os.path.exists('/srv/ocr/%s' % username):
|
||||
os.mkdir('/srv/ocr/%s' % username)
|
||||
|
||||
fd.close()
|
||||
|
Reference in New Issue