Problem with removing Group Members through the Web Service Client.

Jun 14, 2011 at 5:27 PM

RmResourceChanges changes = new RmResourceChanges(group)

changes.BeginChanges();

group.ExplicitMember.Remove(

 
new RmReference("urn:uuid:4254ffe3-c94e-48b5-9644-61f9d55aa96f"));

client.Put(changes);

changes.AcceptChanges();

I can do the same thing with .Add and it works fine..

When I do the remove, I get an "Unable to dispatch request" error..

I have the permissions manually to do this in the portal... Only fails in the webservice call.

The problem seems to be that the removal is never really taking place and RmResourceChanges is coming back with 0 changes... Why the error is occuring..

Anybody have any idea... Been debugging the code and my eyes are going crazy... lol

 

Joe

Coordinator
Jun 14, 2011 at 7:47 PM

Hi Joe,

the problem is that the RmResourceChanges object computes differences based on how the object is defined when you call BeginChanges.

I cannot say if this is the case, as you are not showing how you created the group, but it could be that your group has no values in the ExplicitMember attribute. If so, removing a value has no effect on it, and on the RmResourceChanges object.

Try one of the following:

1) Get the group with a query (make sure that ExplicitMember is among the returned attributes).

2) Use this hack :)

RmReference member = new RmReference("urn:uuid:4254ffe3-c94e-48b5-9644-61f9d55aa96f");
group.ExplicitMember.Add(member); 
changes.BeginChanges();
group.ExplicitMember.Remove(member); 
client.Put(changes);

Hope this helps,
Paolo

Jun 14, 2011 at 7:53 PM

This is what I was using:

DefaultClient client = new DefaultClient();

RmGroup group = null;

 

String filter = String.Format("/Group[{0} = '{1}']", RmResource.AttributeNames.DisplayName.Name, groupDisplayName);

 

foreach (RmResource resource in client.Enumerate(filter))

 

{

group = resource as RmGroup;

 

break;

 

Jun 14, 2011 at 7:58 PM

Looks like there is a problem in getting the group itself, it only wants to grab 1 member and there are 2 members..

So when its passing the group.. it doesn't see the other member. 

Jun 14, 2011 at 8:01 PM
Edited Jun 14, 2011 at 8:03 PM
hi,
try with:
RmResourceChanges changes = new RmResourceChanges(group)

changes.BeginChanges();

group.ExplicitMember.Remove(new RmReference("4254ffe3-c94e-48b5-9644-61f9d55aa96f"));

client.Put(changes);

changes.AcceptChanges();
__
Hammou
Jun 14, 2011 at 8:03 PM

Yes that works.. but why am I only getting 1 member returned with the group... I should be getting 2..

I would rather have an api that works instead of having to hack it.

Thanks though... :)

Jun 14, 2011 at 8:11 PM

Just double-checked... Group has 2 members..

Its only grabbing the first one.

Is there a code update to grab all members for the group?

Coordinator
Jun 15, 2011 at 7:06 AM

Hi Joe,

the code does retrieve all the members of the group if everything is configured correctly, so the problem is somewhere else...

I see you are getting the group by display name, which is not guaranteed to be unique, and in your foreach loop there's a break statement; are you sure that the query is returning only one object, and that you are getting the correct one?

Cheers,

Paolo

 

Jun 15, 2011 at 5:06 PM

There is only 1 group in this environment, so there is no need to worry about uniqueness.

Jun 15, 2011 at 5:23 PM
Edited Jun 15, 2011 at 5:25 PM

Looks like I found the issue.

Client.RefreshSchema

If this is not called before you make the call to pull the group info.. multivalues break..

 

Developer
Jun 15, 2011 at 5:43 PM

Maybe we should put this in the constructor for the client so other people don’t make the same mistake.

-J

From: steponz [email removed]
Sent: Wednesday, June 15, 2011 10:23 AM
To: jeremy@palenchar.net
Subject: Re: Problem with removing Group Members through the Web Service Client. [fim2010client:261366]

From: steponz

Looks like I found the issue.

Client.RefreshSchema

If this is not called before all other calls, Mutlivalues break.......................

Jun 15, 2011 at 6:18 PM

Exactly what I was thinking..   ;)