| | |
| | | */ |
| | | public class LDAPPasswordModify |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class. |
| | | */ |
| | | /** The fully-qualified name of this class. */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.tools.LDAPPasswordModify"; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Parses the command-line arguments, establishes a connection to the |
| | | * Directory Server, sends the password modify request, and reads the |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Parses the command-line arguments, establishes a connection to the |
| | | * Directory Server, sends the password modify request, and reads the |
| | | * response. |
| | | * |
| | | * @param args The command-line arguments provided to this program. |
| | | * |
| | | * @return An integer value of zero if everything completed successfully, or |
| | | * a nonzero value if an error occurred. |
| | | */ |
| | | public static int mainPasswordModify(String[] args) |
| | | { |
| | | return mainPasswordModify(args, true, System.out, System.err); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Parses the command-line arguments, establishes a connection to the |
| | | * Directory Server, sends the password modify request, and reads the |
| | |
| | | PrintStream out = NullOutputStream.wrapOrNullStream(outStream); |
| | | PrintStream err = NullOutputStream.wrapOrNullStream(errStream); |
| | | |
| | | |
| | | // Create the arguments that will be used by this program. |
| | | BooleanArgument provideDNForAuthzID; |
| | | BooleanArgument showUsage; |
| | |
| | | StringArgument propertiesFileArgument; |
| | | BooleanArgument noPropertiesFileArgument; |
| | | |
| | | |
| | | // Initialize the argument parser. |
| | | LocalizableMessage toolDescription = INFO_LDAPPWMOD_TOOL_DESCRIPTION.get(); |
| | | ArgumentParser argParser = new ArgumentParser(CLASS_NAME, toolDescription, |
| | |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | | // Parse the command-line arguments provided to this program. |
| | | try |
| | | { |
| | |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | | // If the usage or version argument was provided, |
| | | // then we don't need to do anything else. |
| | | if (argParser.usageOrVersionDisplayed()) |
| | |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | // Make sure that the user didn't specify any conflicting arguments. |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Get the host and port. |
| | | String host = ldapHost.getValue(); |
| | | int port; |
| | |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | | // If a control string was provided, then decode the requested controls. |
| | | ArrayList<Control> controls = new ArrayList<>(); |
| | | if(controlStr.isPresent()) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Perform a basic Directory Server bootstrap if appropriate. |
| | | if (initializeServer) |
| | | { |
| | | EmbeddedUtils.initializeForClientUse(); |
| | | } |
| | | |
| | | |
| | | // Establish a connection to the Directory Server. |
| | | AtomicInteger nextMessageID = new AtomicInteger(1); |
| | | LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions(); |
| | |
| | | { |
| | | dn = bindDN.getValue(); |
| | | pw = bindPW.getValue(); |
| | | if(pw != null && pw.equals("-")) |
| | | if ("-".equals(pw)) |
| | | { |
| | | // read the password from the stdin. |
| | | try |
| | |
| | | LDAPReader reader = connection.getLDAPReader(); |
| | | LDAPWriter writer = connection.getLDAPWriter(); |
| | | |
| | | |
| | | // Construct the password modify request. |
| | | ByteStringBuilder builder = new ByteStringBuilder(); |
| | | ASN1Writer asn1Writer = ASN1.getWriter(builder); |
| | |
| | | new LDAPMessage(nextMessageID.getAndIncrement(), extendedRequest, |
| | | controls); |
| | | |
| | | |
| | | // Send the request to the server and read the response. |
| | | try |
| | | { |
| | |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // Read the response from the server. |
| | | LDAPMessage responseMessage = null; |
| | | try |
| | |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // Make sure that the response was acceptable. |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | | responseMessage.getExtendedResponseProtocolOp(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // See if the response included any controls that we recognize, and if so |
| | | // then handle them. |
| | | List<Control> responseControls = responseMessage.getControls(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // See if the response included a generated password. |
| | | ByteString responseValue = extendedResponse.getValue(); |
| | | if (responseValue != null) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Unbind from the server and close the connection. |
| | | unbind(nextMessageID, writer); |
| | | close(reader, writer); |
| | |
| | | catch (Exception e) {} |
| | | } |
| | | } |
| | | |