5

How can export all FreeIPA users to a csv file?

2 Answers2

6

This command worked for me:

ipa user-find --all | grep -E "User Login|First|Last|UID|Email" > IPA_RAW.txt

after that, use this perl line to convert the format:

perl -ne 'chomp; print $_ . (($. % 8) ? "," : "\n")' IPA_RAW.txt | awk "Add your filters here" > users-list.csv

thanks

bjoster
  • 5,241
0

Late but full "copy/paste" answer (based on previous ones - thanks - I could have quit after writing ipa2json); for present and future needs.

Export users with:

ipa user-find --all > ipa.txt

If the output is truncated adjust the limit with the command below and retry:

ipa config-mod --searchrecordslimit=######

To use this method you need nodejs on the machine (or container) where you intend to process ipa.txt; for this I suggest using nvm:

# install nodejs version manager (nvm) for the current user (not root!)
wget https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

install the latest nodejs long time support (lts) version for the current user

nvm install --lts

Install the required scripts as command line tools for the current user:

npm i -g ipa2json      # to convert ipa output to json
npm i -g equalizejson  # to spread missing fields in every record
npm i -g json2csv      # to convert the json to csv

Convert ipa output to json with:

ipa2json ipa.txt > ipa.json

Equalize the json (you need all the fields in all the instances for proper csv conversion) and convert to csv :

equalizejson ipa.json | json2csv > ipa.csv

To uninstall nvm, nodejs and the scripts you may just remove the $NVM_DIR folder (usually ~/.nvm), as documented when you type "nvm" in the terminal.