Jump to: navigation, search

Change Password On Next Login

This page shows examples of how a Configuration Server connection can be opened, using either a standard login or with a forced password change on login.

Scenario: Standard Login

The following code shows a standard login process, without this feature enabled:

ConfServerProtocol protocol = new ConfServerProtocol(new Endpoint("cfgsrv", csHost, csPort));
protocol.setClientName(clientAppName);
protocol.setClientApplicationType(clientAppType.ordinal());
protocol.setUserName(userName);
protocol.setUserPassword(userPasswd);
protocol.open();

Scenario: Change Password on Next Login

When the user has enabled the Change Password on Next Login feature, protocol.open() throws ChangePasswordException. This exception should be caught and handled to force the password update.

So the resulting code may look like:

ConfServerProtocol protocol = new ConfServerProtocol(new Endpoint("cfgsrv", csHost, csPort));
protocol.setClientName(clientAppName);
protocol.setClientApplicationType(clientAppType.ordinal());
protocol.setUserName(userName);
protocol.setUserPassword(userPasswd);
try {
  protocol.open();
} catch (ChangePasswordException e) {
  String newPasswd = ...; // obtain new user password
  protocol.useChangePasswordRegistration(newPasswd);
  protocol.open();
}

After a successful open procedure, the new password value will be accepted and protocol.getUserPassword() will be set to the newPasswd value that was specified during login.

Scenario: Standard Login

The following code shows a standard login process, without this feature enabled:

ConfServerProtocol protocol = new ConfServerProtocol(new Endpoint("cfgsrv", csHost, csPort));
protocol.ClientName = clientAppName;
protocol.ClientApplicationType = clientAppType;
protocol.UserName = userName;
protocol.UserPassword = userPassword;
protocol.Open();

Scenario: Change Password on Next Login

When the user has enabled the Change Password on Next Login feature, protocol.open() throws ChangePasswordException. This exception should be caught and handled to force the password update.

So the resulting code may look like:

ConfServerProtocol protocol = new ConfServerProtocol(new Endpoint("cfgsrv", csHost, csPort));
protocol.ClientName = clientAppName;
protocol.ClientApplicationType = clientAppType;
protocol.UserName = userName;
protocol.UserPassword = userPassword;
try
{
  protocol.Open();
}catch(ChangePasswordException)
{
  string newPassword= ...; // obtain new user password
  protocol.UseChangePasswordRegistration(newPassword);
  protocol.Open();
}

After a successful open procedure, the new password value will be accepted and protocol.UserPassword will be set to the newPasswd value that was specified during login.

Feedback

Comment on this article:

blog comments powered by Disqus
This page was last modified on 20 June 2017, at 23:57.