diff options
author | Jonas Smedegaard <dr@jones.dk> | 2007-06-10 09:18:13 +0000 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2007-06-10 09:18:13 +0000 |
commit | 076d907629005e227320e6d734ab4632f4f11f33 (patch) | |
tree | 77aedc49a5f668b9c07cf350e6f7b4b559d71d02 | |
parent | 97a50dc6cf393a39b6735dd6907a8a6526e1f553 (diff) |
New dirty script to convert from getent to LDAP using awk.
-rwxr-xr-x | ldap/userimport.awk | 36 | ||||
-rw-r--r-- | ldap/userimport.sh | 10 |
2 files changed, 46 insertions, 0 deletions
diff --git a/ldap/userimport.awk b/ldap/userimport.awk new file mode 100755 index 0000000..165ee98 --- /dev/null +++ b/ldap/userimport.awk @@ -0,0 +1,36 @@ +BEGIN { FS=":" } +{ +if ($3 > 99) { + printf("dn: cn=%s,ou=People,ou=Entities,ou=SAM,dc=jones,dc=dk\n", $5); + printf("objectclass: top\n"); + printf("objectclass: account\n"); + printf("objectclass: posixAccount\n"); + printf("objectclass: morrisonaccount\n"); + printf("objectclass: morrisonuser\n"); + printf("objectclass: person\n"); + printf("objectclass: organizationalPerson\n"); + printf("objectclass: inetOrgPerson\n"); + printf("objectclass: evolutionPerson\n"); + printf("objectclass: officePerson\n"); + printf("objectclass: mHybridPerson\n"); + printf("objectclass: morrisonperson\n"); + printf("cn: %s\n", $5); + printf("sn: %s\n", substr($5, match($5, " ") + 1)); + printf("morrisonimallow: Y\n"); +} else { + printf("dn: uid=%s,ou=System,ou=Entities,ou=SAM,dc=jones,dc=dk\n", $1); + printf("objectclass: top\n"); + printf("objectclass: account\n"); + printf("objectclass: posixAccount\n"); + printf("objectclass: \n"); +} +printf("uid: %s\n", $1); +printf("uidNumber: %s\n", $4); +printf("gidNumber: %s\n", $3); +printf("userpasswd: {CRYPT}%s\n", $2); +printf("gecos: %s\n", $5); +printf("homeDirectory: %s\n", $6); +printf("loginShell: %s\n", $7); +printf("\n"); +} +END {} diff --git a/ldap/userimport.sh b/ldap/userimport.sh new file mode 100644 index 0000000..ff8d3cf --- /dev/null +++ b/ldap/userimport.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Origin (possibly): http://www.whitemiceconsulting.com/node/101 & http://www.whitemiceconsulting.com/system/files?file=LDAP102.pdf + +# TODO: +# * Handle non-ASCII input +# + ASCIIfy known limited fields (dn, gecos,...) +# + Unicode-wrap the rest: Double first colon, and base64-encode rest of line. + +getent passwd | awk -f userimport.awk |