You are here

Programmatically Change Password

Submitted by wyseguyCO on Mon, 08/31/2009 - 15:18

Has anyone been able to programmatically update a user's password in Luminis?

The reason for my request is that we are in the process of determining the feasibility of using an independent clone of our Luminis LDAP as an authenticating source to set up our same sign-on.  Part of this project will be creating a password self-service site that will allow users to update their passwords for SSB, D2L, and as many other web applications as we can get to authenticate against our cloned LDAP.  We cannot use the internal password mechanisms because we're limited by the fact that we're in the middle of a 13 institution deployment of the portal and not every institution is ready to use the portal.

Luminis Version:

You can do this "quite easily" using the Data Access SDK - provided you have the current password in plain text too.

This should get you started...

import com.sct.pipeline.da.*;


public boolean updatePassword(
    String UserId,
    String currentPassword,
    String newPassword   ){

    // Some defaults
    boolean returnValue = false;
    PasswordModification passwordModification = null;

    if (currentPassword != null && newPassword != null)
        // *** Add your minimum password strength requirements here

        // If the password is to be changed
        if (currentPassword.equals(newPassword))
            //"Password change error: New password == Current password");
            // Passwords are different       
            // _logger.debug("Attempting to change password...");
            PasswordPair passwordPair = new PasswordPair();

            passwordModification = new PasswordModification(

            Modification[] userModifications = new Modification[1] ;
            userModifications[0] =  passwordModification;

            ModifyParams modifyParams =  new ModifyParams();
            modifyParams.setBoId( new BOID( BusinessObjectTypeEnum.USER, userId));

                // StringBuffer().append("User modified: ").append(userId) );

                returnValue = true;
            catch (Exception e)
                _logger.error(new StringBuffer().append("User modification failed: ")
    return returnValue;

I've adapted it from some code I wrote several years ago that's running on our production box.  Can't guarantee the syntax is exactly right though.

Thanks for the code, its given me a couple ideas for how to proceed.  Unfortunately, I'm developing a password update tool and at the point where I need to encrypt and store the new password, the user has established their identity through a challenge question and providing their Banner ID.  At this point in the process, it is assumed the user is not in possession of their existing password.

I've done some research into using the Java classes that do encryption (specifically the Cipher class).  It is my hope that if I can get the correct algorithm and encryption key for our Luminis install that I'll be able to update the LDAP with the new password.

The solution is to not worry about the encryption of the password.  Instead, just modify the LDAP entry using the Java DirContext and ModificationItem classes to update the password.  Luminis' LDAP will automatically encrypt the password prior to storing it using its own internal mechanisms.

Hi Jonathan,
Did you have to deal with the stored secret?
Per SDK's document the PasswordPair handles the secretstore. However, I am running into a problem: if I connect to the DA webservice as luminis admin user then I can change the user's password but it will not update the stored secret. But if I connect to the DA webservice as the same user (which I should) the code did not work and give me some errors as below:
[INFO] JAXRPCService - -Service class com.sct.pipeline.da.Da_Impl implements service {}da
DAExecption caught: com.sct.pipeline.da.DAException: Server error; [1254935660138] password reset failed; [BASE, A wrapper exception, Subject Subject: [uid=541778237991171,ou=People,, hashcode=1801965311 static id=541778237991171] Credentials for [cn=SecretStoreService,ou=SecretStore,ou=Services,,, cn=UserSessionManager,ou=Services,,, cn=DirectoryService,ou=Services,,, cn=HttpAuthenticator,ou=Services,o=Campus, cn=EmailService,ou=Services,,, cn=CalendarService,ou=Services]Subject:
    Principal: "uid=541778237991171,ou=People,,"
    Principal: [ 541778237991171 ]
    Principal: [ filter.162 ]
    Principal: [ sct.public ]
    Principal: [ sct.faculty ]
    Principal: [ filter.148 ]
    Principal: [ filter.114 ]
    Principal: [ filter.117 ]
    Principal: [ filter.107 ]
    Principal: [ filter.115 ]
    Principal: [ filter.135 ]
    Principal: [ filter.113 ]
    Principal: [ filter.109 ]
    Principal: [ filter.104 ]
    Principal: [ filter.105 ]
    Principal: [ filter.134 ]
    Principal: [ filter.126 ]
    Principal: [ filter.154 ]
    Principal: [ filter.133 ]
    Principal: [ filter.155 ]
    Principal: [ sct.Student ]
    Principal: [ filter.120 ]
    Principal: [ filter.106 ]
    Principal: [ filter.153 ]
    Principal: [ filter.112 ]
    Principal: [ pags.UPD_85 ]
    Principal: [ filter.125 ]
    Principal: [ filter.118 ]
    Principal: [ filter.108 ]
    Principal: [ filter.122 ]
    Principal: [ filter.121 ]
    Principal: [ filter.119 ]
    Principal: [ filter.103 ]
    Principal: [ filter.123 ]
 is not yet authenticated]
You mentioned you used both Java DirContext and ModificationItem. Could you collaborate more on why you need to use both?
Thanks in advance.

We used JDNI.

1. Get the context to your ldap
2. Generate an SSHA hash from the clear text password. Combine "{SSHA}" + base 64 encoding of hash + random salt.
3. Modify the attribute userPassword


Can you please elaborate?

So by using JNDI, you did not have to use the DA web service correct?

Also, how did you get the ldap context? I know the JNDI context is usually configured in a Tomcat configuration file, like context.xml , but can you be more specific? Where is that ldap context?