summaryrefslogtreecommitdiff
path: root/bin/ldap2mail
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ldap2mail')
-rwxr-xr-xbin/ldap2mail29
1 files changed, 29 insertions, 0 deletions
diff --git a/bin/ldap2mail b/bin/ldap2mail
new file mode 100755
index 0000000..71eddd9
--- /dev/null
+++ b/bin/ldap2mail
@@ -0,0 +1,29 @@
+#!/usr/bin/ruby
+
+#
+# Copyright (c) 2004 Peter Palfrader <peter@palfrader.org>
+#
+# All rights reserved.
+#
+
+require "ldap"
+require "getoptlong"
+require "myldap"
+require "yaml"
+
+
+@config = YAML::load( File.open( '/etc/noreply/config' ) )
+@basedir = @config['module']['mail']['basedir']
+
+
+ldap = MyLDAP.new(@config, "ldap2mail")
+clients = ldap.conn.search2(@config['basedn'], LDAP::LDAP_SCOPE_SUBTREE, 'objectclass=tnClient')
+
+clients.each { |c|
+ if not File.exists?(@basedir + "/" + c['o'][0])
+ Dir.mkdir(@basedir + "/" + c['o'][0], 02700 )
+ File.chown(c['uidNumber'][0].to_i, c['gidNumber'][0].to_i, @basedir + "/" + c['o'][0])
+ elsif not File.stat( @basedir + "/" + c['o'][0]).directory?
+ STDERR.puts("Warning: #{@basedir}/#{c['o'][0]} is not a directory.");
+ end
+}