Remove role from user using SOAP

Moderator: crythias

Locked
Nicsoft
Znuny newbie
Posts: 53
Joined: 12 Aug 2010, 14:58
Znuny Version: 2.4
Location: Stockholm
Contact:

Remove role from user using SOAP

Post by Nicsoft »

Hello,

I am looking for a way to remove/disconnect a user from a role using the SOAP interface. The natural place to at http://dev.otrs.org/ for this method is at Kernel::System::Group, but there is no such kind of "GroupUserRemoveRole"-method.

Is there a method that's not specified in the docs? It is possible in admin area of OTRS so I assume there is some method to be used.

One way I was thinking of is using the method below and setting Active = 0. Will this do the trick? I don't know what's happening behind the scene if I do this.

Code: Select all

my $Success = $GroupObject->GroupUserRoleMemberAdd(
        UID    => 12,
        RID    => 6,
        Active => 0,
        UserID => 123,
    );
Thanks!

/Niklas
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Remove role from user using SOAP

Post by crythias »

Code: Select all

GroupRoleMemberAdd()
to add a role to a group
    Permission: ro,move_into,priority,create,rw
    $GroupObject->GroupRoleMemberAdd(
        GID => 12,
        RID => 6,
        Permission => {
            ro        => 1,
            move_into => 1,
            create    => 1,
            owner     => 1,
            priority  => 0,
            rw        => 0,
        },
        UserID => 123,
    );
setting permissions to 0 seems to be adequate. Need all 4 entries, though:

Code: Select all

    for (qw(RID GID UserID Permission)) {
        if ( !$Param{$_} ) {
            $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Nicsoft
Znuny newbie
Posts: 53
Joined: 12 Aug 2010, 14:58
Znuny Version: 2.4
Location: Stockholm
Contact:

Re: Remove role from user using SOAP

Post by Nicsoft »

But this has nothing to do with removing the user from the role-list, this is about roles vs. groups. I think the UserID you are using is for the user that made the actual change and is not used for any changes of permission, rigth?
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Remove role from user using SOAP

Post by crythias »

ack. You're saying this is the group's involvement in the role? Sorry. Your original should have been right, then.

Kernel/Modules/AdminRoleUser.pm does this:

Code: Select all

        # add or remove user from roles
        for my $UserID ( keys %UserData ) {
            my $Active = 0;
            for my $MemberOfRole (@IDs) {
                next if $MemberOfRole ne $UserID;
                $Active = 1;
                last;
            }
            $Self->{GroupObject}->GroupUserRoleMemberAdd(
                UID    => $UserID,
                RID    => $ID,
                Active => $Active,
                UserID => $Self->{UserID},
            );
        }
I apologize for the mistake.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Nicsoft
Znuny newbie
Posts: 53
Joined: 12 Aug 2010, 14:58
Znuny Version: 2.4
Location: Stockholm
Contact:

Re: Remove role from user using SOAP

Post by Nicsoft »

No problem, thanks for your input!
Locked