[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: AW: script for adding users information in ldap database
On Wed, Jul 16, 2008 at 5:15 PM, Kristen Walker <kwalker@sbceo.org> wrote:
> I have a question along similar lines. We use Uportal and Moodle and I want
> to set up an LDAP server for those applications to authenticate users. I
> want to take the users in the Uportal MySQL database and migrate them to an
> LDIF file. Has anyone done this? I am assuming I will have to write some
> sort of script to create the LDIF file. Does anyone have an example of a
> script that does something similar? Anything that involves getting data out
> of a MySQL database and creating an LDIF file with it would be really
> helpful.
mysql -u root -p -e 'select email, password from posta.users' | awk
'NR != 1 { printf "dn: uid=%s, dc=example\nobjectclass:
myObjectClass\nuserpassword: %s\n\n", $1, $2 }'
(the NR != 1 part is required to discard the first line mysql outputs)
this is how i migrated my mail users from mysql to ldap, it has a
catch tho, it won't work if your records have spaces in them. in that
case you are probably better with perl than with shell, but since i'm
a bash guy and not a perl guy i'd do stuff like:
mysql -u root -p -e $'select email, "\a", password from posta.users'
| awk -F$'\a' 'NR != 1 { printf "dn: %s\nobjectclass:
myObjectClass\nuserpassword: %s\n\n", $1, $2 }'
it requires bash and it will work as long as your fileds don't have an
ascii bell in them.
--
For far too long, power has been concentrated in the hands of "root"
and his "wheel" oligarchy. We have instituted a dictatorship of the
users. All system administration functions will be handled by the
People's Committee for Democratically Organizing the System (PC-DOS).