That info tab with all it’s empty fields has been taunting me with all it’s wonderful uses, but sitting down and filling in 500+ users with all their individual data is not something even I’d wish on my worst enemy!
Read On for details on how to have all the fields filled in 30 minutes or less…The biggest issue I faced when starting working on this was figuring out where my data was coming from. So many people have this data already, but getting it into a format that will easily import into LDAP was the real challenge. Asking around, it seemed that spreadsheets and databases were the norm, both or which have some sort of function to export to a comma delimited file (csv), so this was my jumping off point.
Setting up your csv file is probably going to be the toughest part of this whole exercise, you have to put it in a specific order – otherwise you’re going to end up with your users residing in their phone numbers… So, here’s the order of the csv file:
<code> shortname,street,city,state,zip,country,work tel,mobile tel,fax,pager,mail,mail2,mail3,aim,jabber,msn,icq,yahoo,url,blog </code>
This is pretty close to the order found in the info tab now in Workgroup Manager. There are a couple caveats to this however, because the script is using ldapmodify to bring in all this data for us, it will result in an error and no data being imported if there are blanks left in your csv file. The other thing to note is that the mail addresses need to be distinct – for example, in my testing I had my 3 e-mail addresses as follows:
<code> ...,[email protected],none,none,... </code>
This didn’t work as ldapmodify was seeing the two “none” addresses as the same entry. It’s only the multiple e-mails this affects, the IM accounts are handled differently.
A little information on csv files: Check your csv in a very simple text editor before running with it, some applications have a habit of not creating line breaks correctly when exporting to csv – a simple test of this is simply viewing your csv file in the terminal – if you’re seeing a lot of unrecognizable characters where you’d expect to see line breaks, you’ve created your csv with one of these applications. Drop your csv into vi, TextWrangler or even TextEdit, and do a find and replace on the fake line break and replace it with a real one.
Notes on actually running the script:
<code> ./info_filler [ldap_admin] [ldap_password] [ldap server] [path/to/csv_file] </code>
<code> DC_PART1="example" DC_PART2="com" </code>
The script is available for download from our scripts archive here.