Article

tleerhoff's picture
article
Reads:

7457

Score:
0
0
 
Comments:

3

Easier editing an exported LDIF file for hundreds of entries

Author Info

29 September 2010 - 2:47pm
Submitted by: tleerhoff

(View Disclaimer)

Anyone trying this for the first time I would suggest you try a short list of users to try this on. This makes it easier to verify each entry prior to going to the next step, plus let you get more comfortable with the process..

My Needs:

With the migration of servers to OES-Linux there is a need for all users to have the uniqueID attribute populated.

My goals:

  1. Take a user export LDIF file via ConsoleOne
  2. Add the attribute uniqueID for each user into the file
  3. Import the file back into eDirectory with ConsoleOne

Software I used:

You should be able to use other software packages as long as they have the capabilities to do the processes I do.

  1. XP-pro workstation with the latest patches
  2. Latest Novell Client
  3. ConsoleOne 1.3.6h eith the latest eDirectory snapin
  4. Wordpad (part of XP)
  5. MS Excel
  6. MS Word

Process I used:

Goal 1 - Adding uniqueID attributes to all users

  • ConsoleOne 1.3.6h
  • Word 2003+
  • Excel 2003+
  • Wordpad (on WinXP)

Goal - Export users into a LDIF

  • Open ConsoleOne
  • Wizards
  • NDS Import/Export…
  • Click Export LDAF File radio button
  • Click Next
  • Fill in the following fields:
  • Server IP Address: ip of OES server
  • Port: 389
  • Authenticated Login
  • User DN: cn=admin
  • o=novell (this is in fully qualified LDAP format so use a comma)
  • Password: password for above user (duh)
  • Click on Next
  • Enter the top level context your users are within use fully qualified LDAP format again in this example ou=users,o=novell
  • Click on the Filter tab
  • Change the ojjectclass from * to user
  • Click on the Attributes tab
  • Click the Attributes radio button
  • Click on the List… button
  • In the attribute field enter dn
  • And click on the add button
  • Enter uniqueID
  • Click on the add button
  • Click on close
  • Click on the Next > button
  • Enter a file name and path – I am using c:\t\user-uid.ldif
  • Click on the Next > button
  • Verify the info and client on Finish to do the export
  • You should see something like:
  • Click on the Close button

OK the file is exported

Optional edit:

Depending on how many users you just exported you might want to edit out any user that already has a uniqueID.

  • Open Wordpad:
  • Open the above file

The users with a Unique ID already will have 3 lines associated with them (a changetype, and a uniqueID line are the additional lines)

You can just delete all 3 of these lines for each user that has a uniqueID, but be careful to not delete any single line.

Then save again.

Goal 2 - Mass Editing

I know this seems like a long way around but with 3000+ users I had to look at this was FAR faster.

  • Open Excel
  • File Open - point to the file we just saved
  • This should bring up a text import window.
  • Go with fixed width

    And make sure there are no column breaks

    Note no vertical lines dividing the file

  • Click finish
  • Do a File Save-as and choose a temporary file name (so we do not accidentally wrote over our original data
  • Highlight the A column and sort
  • All you want are the lines starting DN:
  • Delete all the rest
  • Once done you should have a list of users looking like:
  • In cell B1 enter: changetype: modify
  • In cell C1 enter: add: uniqueID
  • In cell F1 enter this formula: =FIND(",",A1)
  • In cell E1 enter this formula: =MID(A1,8,F1-8)
  • In cell D1 enter this formula: =CONCATENATE("uniqueID: ",E1)
    B1 needed to add the attribute to the user
    C1 adds the attribute to the user
    F1 identifies the location of the first non-CN in A1
    E1 carves out the user ID (CN) from A1
    D1 adds the needed uniqueID in front of the User name for import purposes.
  • Highlight cells B1-F1
  • Hover over the little black box in the lower right of the highlight hold down the control key and double click.
  • This will copy the formulas down the entire length of the data in column A
  • You should have something that now looks like the following:
  • Highlight the first 4 columns right click and copy
  • Open a new sheet in the Excel file
  • Highlight cell A1
  • right click and choose paste special
  • Choose text or values (depends on your version of Excel)
  • Click on the OK button
    This keeps the info but gets rid of all the formulas.
    Do a File Save-as
    Choose a CSV file format
  • Enter a new name that you will remember. – I chose user-uid.csv
  • Open Word and open the file just saved
  • You should see something like:

    Since we need to get rid of some of the commas but not all, I save the commas between the quotes by choosing a place holding character like [

  • I do a replace (Control-H) on ,ou= and replace it with [ou=
  • Then I do a replace on ,o= and replace it with [o=
  • You can now replace all “ with nothing to get rid of the un-needed quotes
  • Now I change the remaining commas into carriage returns doing a replace like this:
  • Replace , with a ^p (paragraph marker)
  • You should now see something like the following:
  • Now we replace the place holders with commas

  • Finally Adding a line separation between every user

  • Replace dn: with ^pdn:
  • And that should get you close to a LDIF file that looks like:
  • All that is left is to add the ldif header which we can copy from the original export file
  • And your LDIF file should now look like:
  • Do a file-save-as and choose plain text format – e.g. final-uid.ldif
  • Agreeing to the warnings

Goal 3 - Import back into eDirectory

  • Open ConsoleOne
  • Wizards
  • NDS Import/Export…
  • Click Import LDAF File radio button (should be the default)
  • Click Next
  • Fill in the following fields:
  • Server IP Address: ip of OES server
  • Port: 389
  • Authenticated Login
  • User DN: cn=admin

Note the errors, not a big deal, they are probably errors that the user already has the uniqueID attribute filled in.

I have found one gotcha in that the import would only do 250 users at a time.

All I did was delete the top 240 or so users and resave the file restarting the import.

Took me a few runs as the last time I did this there were over 3000 users in the export.


Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).

It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.




User Comments

higgi77's picture

Another way...

Submitted by higgi77 on 30 September 2010 - 4:53am.

is the batch function from Apache LDAP Studio.

tbundy427's picture

Not quite working here....

Submitted by tbundy427 on 9 March 2011 - 8:57am.

In cell F1 enter this formula: =FIND(",",A17)

should be

In cell F1 enter this formula: =FIND(",",A1)

tbundy427's picture

However....

Submitted by tbundy427 on 10 March 2011 - 6:15am.

Other than the one typo, this works fine. ALL of my 1722 user objects now have a uniqueID. Thanks for creating this article!

© 2013 Novell