[rt-users] "No object mapping for field" when referencing the UserObject of a MembersObject...
Johnathan Bell
johnathan.bell at baker.edu
Thu May 21 15:11:07 EDT 2009
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
More information about the rt-users
mailing list