Using mldap_modify & mldap_delete functions in LoadRunner

Posted on September 20th 2011 by Joel Deutscher

Deleted
I have written before about using the LDAP protocol using LoadRunner. This time, I had a requirement to reset the passwords for all my test users before an execution. Luckily for me, there was already some shell scripts setup that utilised ldapmodify, so it was just a matter of converting them over to LoadRunner scripts.

After binding to the LDAP server, the first command was to delete the users password history to get around the password policy. The batch file called the ldapmodify function like below

ldapmodify -h ldap.headwired.com -p 389 -D 'cn=Directory Manager' -w PASSWORD <

As the action is actually a delete, this translates to the mldap_delete function in LoadRunner.

// Clear Password History
mldap_delete("LDAP Delete", 
      "DN=uid={USERNAME},ou=people,dc=headwired,dc=com ", 
      "AttrName=passwordHistory", 
      LAST );

The next step was reseting the actual password, and here is the script again. Note that as the script must authenticate every time it calls ldapmodify.

ldapmodify -h ldap.headwired.com -p 389 -D 'cn=Directory Manager' -w PASSWORD <

This time, we will use the mldap_modify function to change the userpassword value

// Update Password
mldap_modify("LDAP Modify", 
      "DN=uid={USERNAME},ou=people,dc=headwired,dc=com", 
      "AttrName=userpassword",   // Name of attribute 
      "AttrValue={PASSWORD}",    	// New Value 
      LAST );

While the task to be performed here is very trivial, it’s a simple demonstration of the mldap_modify and mldap_delete functions. The full script is below.

Action()
{
  // LDAP Bind
  mldap_logon("TRANSACTION_NAME",
        "URL=ldap://cn=Directory Manager:[email protected]:389/ ",
        "Version=3",
        "Mode=Async",
        LAST);

  // Clear Password History
  mldap_delete("LDAP Delete", 
        "DN=uid={USERNAME},ou=people,dc=headwired,dc=com ", 
        "AttrName=passwordHistory", 
        LAST );

  // Update Password
  mldap_modify("LDAP Modify", 
        "DN=uid={USERNAME},ou=people,dc=headwired,dc=com", 
        "AttrName=userpassword",   // Name of attribute 
        "AttrValue={PASSWORD}",    	// New Value 
        LAST );

  return 0;
}

About the Author

Joel Deutscher is an experienced performance test consultant, passionate about continuous improvement. Joel works with Planit's Technical Testing Services as a Principal Consultant in Sydney, Australia. You can read more about Joel on LinkedIn.

Comments are closed.