Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load Testing

Status
Not open for further replies.

stu78

Programmer
May 29, 2002
121
GB
Hi,

I need to create a file to add 300000 users to a directory server. The input should look like this;

Objectclass: User
DN: CN=[XXX123],OU=newaccounts,DC=domain,dc=com
CN: XXX123
userAccountControl: 66080.
sAMAccountName: XXX123
userPrincipalName: xxx123@domain.com

I need to create a file that looks like this for 300000 users. The XXX123 bit will be unique to each user, but the constraints are that it should start with some say 6 random letters, and end with 3 random numbers.

The attributes;

DN:
CN:
sAMAccountName:
and userPrincipalName

Should all use this new random value.

I would really appreciate help on this.

STU
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi -

I have tried using mail merge in MS Word - someone suggested scripting this, but I have never done this before.

Any help is appreciated,
Stu
 
Try this...

The first part generates 350000 random IDs, then sorts them, removes the duplicates (when I generated 300000 I ended up with 2500 or so duplicates), and stores them in a file called random_ids.

The second part reads that file and inserts them in the format that you wanted. It could be done in one pipeline, but I think it's clearer like this.

Code:
awk '
        BEGIN {
                for (i=0; i<350000; i++) {
                        printf("%c%c%c%03d\n",
                                (rand*26)+65,
                                (rand*26)+65,
                                (rand*26)+65,
                                rand*1000)
                }
        }
' | sort | uniq | head -300000 > random_ids

awk '
        {
                print "Objectclass: User"
                print "DN: CN=[" $1 "],OU=newaccounts,DC=domain,dc=com"
                print "CN: " $1
                print "userAccountControl: 66080."
                print "sAMAccountName: " $1 ""
                print "userPrincipalName: " tolower($1) "@domain.com"
        }
' random_ids > userfile

Annihilannic.
 
Just a thought, do we have to use the random numbers or can we start with a 100000 and start incrementing by 1. Similarly for the alphabets too - incrementing AAA to AAB, AAC and so on?
 
Annihilannic, you may simplify your suggestion like this:
Code:
awk '
        BEGIN {
                for (i=0; i<350000; i++) {
                        printf("%c%c%c%03d\n",
                                (rand*26)+65,
                                (rand*26)+65,
                                (rand*26)+65,
                                rand*1000)
                }
        }
' | sort -u | awk '
        NR<=300000{
                print "Objectclass: User"
                print "DN: CN=[" $1 "],OU=newaccounts,DC=domain,dc=com"
                print "CN: " $1
                print "userAccountControl: 66080."
                print "sAMAccountName: " $1 ""
                print "userPrincipalName: " tolower($1) "@domain.com"
        }
' > userfile

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top