summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2013-12-30 16:18:16 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2013-12-30 16:18:16 (GMT)
commitc9e1f58986f63700853b9659daa001bebf800f73 (patch)
tree58a4eb9283abaa383728b53ae7bc70fa53e77b1b
parentff596fc526f150e1416e4aba00ef5a547865aea3 (diff)
downloadpfwbged.ocrloader-c9e1f58986f63700853b9659daa001bebf800f73.zip
pfwbged.ocrloader-c9e1f58986f63700853b9659daa001bebf800f73.tar.gz
pfwbged.ocrloader-c9e1f58986f63700853b9659daa001bebf800f73.tar.bz2
add script to fill ocr config from LDAP (#3455)
-rw-r--r--generate-ldap-users.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/generate-ldap-users.py b/generate-ldap-users.py
new file mode 100644
index 0000000..4f70f67
--- /dev/null
+++ b/generate-ldap-users.py
@@ -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()
+