[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: AW: script for adding users information in ldap database
Thank you! This is exactly what I was looking for.
Thanks a million,
Kristen
--
Kristen Walker
Digital Media Resources Developer
Instructional Media Services
Santa Barbara County Education Office
4400 Cathedral Oaks Road
P.O. Box 6307
Santa Barbara, CA 93160-6307
(805)964-4711 ext. 5244/FAX (805)683-3597
kwalker@sbceo.org
http://www.sbceoportal.org
On 7/16/08 9:36 AM, "Almir Karic" <redduck666@gmail.com> wrote:
> 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.