| | |
| | | import org.opends.admin.ads.ADSContextException; |
| | | import org.opends.admin.ads.ADSContext.AdministratorProperty; |
| | | import org.opends.admin.ads.ADSContextException.ErrorType; |
| | | import org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.ReturnCode; |
| | | import org.opends.server.tools.dsconfig.ArgumentExceptionFactory; |
| | | import org.opends.server.util.args.Argument; |
| | | import org.opends.server.util.args.ArgumentException; |
| | |
| | | import org.opends.server.util.table.TableBuilder; |
| | | import org.opends.server.util.table.TextTablePrinter; |
| | | |
| | | import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*; |
| | | /** |
| | | * This class is handling user Admin CLI. |
| | | */ |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ReturnCode performSubCommand(SubCommand subCmd, |
| | | public DsFrameworkCliReturnCode performSubCommand(SubCommand subCmd, |
| | | OutputStream outStream, OutputStream errStream) |
| | | throws ADSContextException, ArgumentException |
| | | { |
| | | |
| | | ADSContext adsCtx = null; |
| | | InitialLdapContext ctx = null; |
| | | ReturnCode returnCode = ReturnCode.ERROR_UNEXPECTED; |
| | | DsFrameworkCliReturnCode returnCode = ERROR_UNEXPECTED; |
| | | |
| | | try |
| | | { |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | adsCtx.createAdministrator(map); |
| | | |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | else |
| | | // ----------------------- |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | adsCtx.deleteAdministrator(map); |
| | | |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | else |
| | | // ----------------------- |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | Set<Map<AdministratorProperty, Object>> adminUserList = adsCtx |
| | |
| | | out.println(AdministratorProperty.UID.getAttributeName() + ": " |
| | | + user.get(AdministratorProperty.UID)); |
| | | } |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | else |
| | | // ----------------------- |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | Set<Map<AdministratorProperty, Object>> adsAdminUserList = adsCtx |
| | |
| | | } |
| | | out.println(); |
| | | } |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | else |
| | | // ----------------------- |
| | |
| | | ctx = argParser.getContext(outStream, errStream); |
| | | if (ctx == null) |
| | | { |
| | | return ReturnCode.CANNOT_CONNECT_TO_ADS; |
| | | return CANNOT_CONNECT_TO_ADS; |
| | | } |
| | | adsCtx = new ADSContext(ctx); |
| | | adsCtx.updateAdministrator(map, newServerId); |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | else |
| | | // ----------------------- |
| | |
| | | } |
| | | TextTablePrinter printer = new TextTablePrinter(outStream); |
| | | table.print(printer); |
| | | returnCode = ReturnCode.SUCCESSFUL; |
| | | returnCode = SUCCESSFUL; |
| | | } |
| | | // ----------------------- |
| | | // ERROR |