#!/bin/bash #A script to generate a LDIF file of random users and associated organizational units #supports emitting ldif files for: Active Directory, eDirectory, OpenLDAP ################################################################################ #Change these variables as needed # ################################################################################ #Number of users to generate #Valid range is from 1 to 10,000 NUMUSERS="11" #Type of directory server to generate ldif for #Valid types (case sensitive): #OPENLDAP #ACTIVEDIRECTORY #EDIRECTORY DIRSERVERTYPE="OPENLDAP" ################################################################################ #!!!!!!!!!!!!!!!!!!!!DO NOT CHANGE ANYTHING BEYOND THIS LINE!!!!!!!!!!!!!!!!!!!# ################################################################################ USERCOUNTER="1" NAMESOURCEFILE="./names.txt" OUSOURCEFILE="./ou.txt" OUTPUTFILE="bulkUserLoad-$DIRSERVERTYPE-$(date +%m%d%Y).ldif" function ldifEmit-OpenLDAP() #Code to emit an OpenLDAP compliant ldif #Bits and bobs sourced from: # # # { cat<>$OUTPUTFILE $FIRSTNAME $LASTNAME $OU OpenLDAP } function ldifEmit-ActiveDirectory() #Code to emit an Active Directory compliant ldif #Bits and bobs sourced from: # # # { echo "Emitting ActiveDirectory ldif..." cat<>$OUTPUTFILE $FIRSTNAME $LASTNAME $OU ActiveDirectory ActiveDirectory } function ldifEmit-eDirectory() #Code to emit an eDirectory compliant ldif #Bits and bobs sourced from: # # # { echo "Emitting eDirectory ldif..." cat<>$OUTPUTFILE $FIRSTNAME $LASTNAME $OU eDirectory eDirectory } function main() { #Range / value check on user supplied variables if [ $NUMUSERS -lt 1 -o $NUMUSERS -gt 50000 ]; then echo "Number of users not correctly specified" echo "Valid range is from 1 to 10,000" echo "Exiting now...." exit 1 fi echo "Number of user range is ok..." if [ -z $NUMUSERS ]; then echo "Number of users not specified." echo "A value of 1 to 10,000 must be specififed." echo "Exiting now...." exit 1 fi if [ -z $DIRSERVERTYPE ]; then echo "Directory server type not specified." echo "Exiting now...." exit 1 fi rm -f $OUTPUTFILE cat <