Import Bulk OU from csv

I’ve found how to create/import multiple ou’s at once using a script

  1. Create a script file, save with name create_ou.sh

#!/bin/bash
#ls --format=single-column

filename=‘ou_add.csv’

while IFS=, read -a csv_line;

do

samba-tool ou create ou=${csv_line},ou=Sentra\ Inovasi\ Solusi,dc=ad,dc=sentrainovasi,dc=com

done < $filename

exit 0

  1. Create a csv file containing a list of ou to be created

IT
Marketing
Admin

  1. run command

#chmod +x create_ou.sh

  1. run script by command

./create_ou.sh

done.
Thanks.

Using the UDM should be the better way, I guess.
Instead of using samba-tool, you can use the command

udm container/ou create --position="ou=Sentra\ Inovasi\ Solusi,dc=ad,dc=sentrainovasi,dc=com" --set name="$csv_line"
1 Like

Thanks sir. but ,why is using udm better? I want to know the reason,

To be honest, I never worked with samba-tool, there might be no benefit for this task.
But your are using the UCS, so why not using the tools which are shipped with it?
The UDM is a mighty tool to do administrative tasks. And the integration within the UCS is for sure better than a standalone tool. Otherwise you could use ldapadd and ldapmodify, too.

1 Like

Thanks sir, Yes, I think that’s right.
i have a problem when ou name list using spaces (ex. IT Operations / IT\ Operations) and it doesn’t work in samba-tool, but when i use udm, everything works normally, thanks a lot.

1 Like