Juan Hernandez has uploaded a new change for review. Change subject: core: Accept directory user in AddUser command ......................................................................
core: Accept directory user in AddUser command Currently the parameter class for the AddUser command has fields for VdcUser, LdapUser and LdapGroup, but the command only works correctly if it gets a VdcUser or a LdapGroup, it will fail if only given a LdapUser. In the future we wan't to be able to use only directory users and groups (althought groups should go to a different command) and not VdcUser. To simplify this future change this patch modifies the command so that it will work correctly if only given the LdapUser. Change-Id: I5caee3a8e295a13c52ed7ea243b1fc25b7603da6 Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddUserCommand.java 1 file changed, 14 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/83/17683/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddUserCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddUserCommand.java index d53be88..7947156 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddUserCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddUserCommand.java @@ -42,7 +42,19 @@ } // set the AD user on the parameters to save another roundtrip to the AD when adding the user getParameters().setAdUser(adUser); - } else if (getParameters().getAdGroup() != null) { + } + else if (getParameters().getAdUser() != null) { + addCustomValue("NewUserName", getParameters().getAdUser().getUserName()); + userId = getParameters().getAdUser().getUserId(); + domain = getParameters().getAdUser().getDomainControler(); + LdapUser adUser = (LdapUser) LdapFactory.getInstance(domain).RunAdAction(AdActionType.GetAdUserByUserId, + new LdapSearchByIdParameters(domain, userId)).getReturnValue(); + if (adUser == null) { + addCanDoActionMessage(VdcBllMessages.USER_MUST_EXIST_IN_DIRECTORY); + return false; + } + } + else if (getParameters().getAdGroup() != null) { addCustomValue("NewUserName", getParameters().getAdGroup().getname()); userId = getParameters().getAdGroup().getid(); domain = getParameters().getAdGroup().getdomain(); @@ -65,7 +77,7 @@ @Override protected void executeCommand() { - if (getParameters().getVdcUser() != null) { + if (getParameters().getAdUser() != null) { UserCommandBase.persistAuthenticatedUser(getParameters().getAdUser()); } // try to add group to db if adGroup sent -- To view, visit http://gerrit.ovirt.org/17683 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5caee3a8e295a13c52ed7ea243b1fc25b7603da6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches