[rt-users] "No object mapping for field" when referencing the UserObject of a MembersObject...

Ruslan Zakirov ruslan.zakirov at gmail.com
Thu May 21 15:35:12 EDT 2009


You need a user object loaded that represents actor - a user who
changing things. GetCurrentUser function is for command line tools
that can be executed by many users on your system, like bin/rt tool.
If you don't need mulit-user script then you can use $RT::SystemUser.
Each object you construct using ->new call needs the current user
provided as the only argument of the method.

In the script below you messing two concepts. You're trying to add
user X as member into a group acting under user X's credentials. If
user X has no rights to modify membership of the group X then he
obviously gets "permissions denied" error.

On Thu, May 21, 2009 at 11:11 PM, Johnathan Bell
<johnathan.bell at baker.edu> wrote:
> Thanks... But another snippet on that page is now giving me trouble...
>
> --code--
> my $currentUser = GetCurrentUser();
> $currentUser->Load("tester97");
> my ($status, $msg) = $groupObj->AddMember($currentUser->id());
> die $msg unless $status;
> exit(0);
> --/code--
>
> That code dies stating "Permission Denied"... do I need to authenticate
> as root first? The perldoc on CurrentUser_Overlay.pm is a bit to obscure
> for me and an example would really help.
>
> Thanks again,
> Johnathan
>
> Ruslan Zakirov wrote:
>> There is example in:
>> http://wiki.bestpractical.com/view/CodeSnippets
>>
>> On Thu, May 21, 2009 at 10:11 PM, Ruslan Zakirov
>> <ruslan.zakirov at gmail.com> wrote:
>>
>>> As group may have another group as meber as well as user, so records
>>> in GroupMembers and CachedGroupMembers objects reference Principals.
>>>
>>> If you are looking for users only that are members of a group then
>>> it's easier to do the following:
>>>
>>> my $group = ...
>>> $group->Load...
>>>
>>> my $users = $group->UserMembersObj;
>>> while ( my $user = $users->Next ) {
>>>   ...
>>> }
>>>
>>> On Thu, May 21, 2009 at 9:46 PM, Johnathan Bell
>>> <johnathan.bell at baker.edu> wrote:
>>>
>>>> Please let me know if this is supposed to go to RT-Users or RT-Devel.
>>>>
>>>> I'm trying to write a utility to interface with Request Tracker, and
>>>> part of what that utility has to do is get the members of some user
>>>> created groups. Just sub in actual groups for what you want in there,
>>>> CurrentUser works and is already initialized by the time my program gets
>>>> here. Mostly borrowing this code from the old rtimportldap script, I
>>>> came up with this:
>>>>
>>>> --code--
>>>>    # RT Group
>>>>    $groupObj = new RT::Group($CurrentUser);
>>>>    $groupObj->LoadUserDefinedGroup($groupName);
>>>>    $groupObj->Id() || die "Group ".$groupName." not found in
>>>> RequestTracker";
>>>>
>>>>    $groupMembersObj = $groupObj->MembersObj();
>>>>    print $groupObj->Id().":".$groupObj.":".$groupMembersObj.":"
>>>>        .$groupMembersObj->Next()->UserObj()."\n"; ## This creates an error
>>>>    while ( $groupMember = $groupMembersObj->Next() )
>>>>    {
>>>>        $groupMemberUser = $groupMember->UserObj();
>>>>        print $groupMemberUser->Name()."\n"; ## This does too
>>>>        #$memberName = $groupMemberUser->Name();
>>>>        #push(@rtMembers, $memberName);
>>>>    }
>>>> --/code--
>>>>
>>>> What it seems is that GroupObj->MembersObj()->Next()->UserObj() causes
>>>> the problem, as UserObj() returns, not a UserObject, but a string
>>>> stating "No object mapping for field" Attempting to use the Name()
>>>> function of course doesn't work because "No object..."->Name() doesn't
>>>> make sense... What's going on?
>>>>
>>>> Thanks,
>>>> Johnathan
>>>>
>>>> --
>>>> Johnathan Bell
>>>> Internet System Administrator, Baker College
>>>>
>>>> _______________________________________________
>>>> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>>>>
>>>> Community help: http://wiki.bestpractical.com
>>>> Commercial support: sales at bestpractical.com
>>>>
>>>>
>>>> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
>>>> Buy a copy at http://rtbook.bestpractical.com
>>>>
>>>>
>>>
>>> --
>>> Best regards, Ruslan.
>>>
>>>
>>
>>
>>
>>
>
> --
> Johnathan Bell
> Internet System Administrator, Baker College
>
>
>
>
> --
> Johnathan Bell
> 810.766.4097
>
> Office Hours: 7A-4P, M-F
> Internet System Administrator, Baker College
>
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>



-- 
Best regards, Ruslan.



More information about the rt-users mailing list