summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2014-03-31 11:30:19 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2014-03-31 11:30:19 (GMT)
commita56fda0858769910fd89ebdb546df80b8a156508 (patch)
tree76d49cad7423f6b338578de083385291e07c709a
parent510eda789540bfbc24ae95a7120e1c0b69227857 (diff)
downloadpfwbged.ocrloader-a56fda0858769910fd89ebdb546df80b8a156508.zip
pfwbged.ocrloader-a56fda0858769910fd89ebdb546df80b8a156508.tar.gz
pfwbged.ocrloader-a56fda0858769910fd89ebdb546df80b8a156508.tar.bz2
add a configuration file to generate-ldap-users
-rw-r--r--generate-ldap-users.py25
-rw-r--r--ldap.ini7
2 files changed, 24 insertions, 8 deletions
diff --git a/generate-ldap-users.py b/generate-ldap-users.py
index 35b0591..208d124 100644
--- a/generate-ldap-users.py
+++ b/generate-ldap-users.py
@@ -1,5 +1,6 @@
#! /usr/bin/env python
+import ConfigParser
import optparse
import os
import ldap
@@ -7,19 +8,19 @@ import sys
parser = optparse.OptionParser()
-parser.add_option('--template', dest='template_filename', default='ocrloader.ini')
+parser.add_option('--config', dest='config', default='ldap.ini')
parser.add_option('--output', dest='output_filename',
default='ocrloader-complete.ini')
-parser.add_option('--ldap-uri', dest='ldap_uri', default='ldap://ldap.pcf.be')
-parser.add_option('--binddn', dest='binddn',
- default='cn=ldap,ou=ouAdmin,ou=ouUsers,dc=win,dc=info,dc=pcf')
parser.add_option('--bindpw', dest='bindpw')
(options, args) = parser.parse_args()
if not options.bindpw:
parser.error('Missing LDAP bind password')
-ldap_conn = ldap.initialize(options.ldap_uri)
-ldap_conn.simple_bind_s(options.binddn, options.bindpw)
+cfg = ConfigParser.ConfigParser()
+cfg.read(options.config)
+
+ldap_conn = ldap.initialize(cfg.get('general', 'ldap_uri'))
+ldap_conn.simple_bind_s(cfg.get('general', 'bind_dn'), options.bindpw)
usernames = []
@@ -36,9 +37,11 @@ for entry in ldap_conn.search_s("dc=win,dc=info,dc=pcf", ldap.SCOPE_SUBTREE, "ob
usernames.append(username)
fd = file(options.output_filename, 'w')
-print >> fd, file(options.template_filename).read()
+print >> fd, file(cfg.get('general', 'template')).read()
for username in usernames:
+ vars = {'username': username, 'username_lower': username.lower()}
+ vars.update(dict(cfg.items('variables')))
print username
print >> fd, '''[ged-%(username_lower)s@pfwb.be]
default_type = dmsdocument
@@ -48,7 +51,13 @@ user = %(username)s
[ged-file-%(username)s@pfwb.be]
store_path = /srv/ocr/%(username)s
-''' % {'username': username, 'username_lower': username.lower()}
+[ged-test-%(username_lower)s@pfwb.be]
+ged_base_url = %(test_server_url)s
+default_type = dmsdocument
+default_directory = Members/%(username)s
+user = %(username)s
+
+''' % vars
if not os.path.exists('/srv/ocr/%s' % username):
os.mkdir('/srv/ocr/%s' % username)
diff --git a/ldap.ini b/ldap.ini
new file mode 100644
index 0000000..3154d5e
--- /dev/null
+++ b/ldap.ini
@@ -0,0 +1,7 @@
+[general]
+template = ocrloader.ini
+ldap_uri = ldap://ldap.pcf.be
+bind_dn = cn=ldap,ou=ouAdmin,ou=ouUsers,dc=win,dc=info,dc=pcf
+
+[variables]
+test_server_url = http://test.ged.pfwb.be