Hi,
I am trying to find out what permissions a specific user has on projects he is assigned to.
A snip of the DB looks like this:
User 1:N Membership M:1 Group 1:N RessourcePermission M:1 Ressource 1:1 Project.
So I need to be able to read details on User, RessourcePermission and Project.
I have tried to "begin" from both User and Project perspective, but in the code below i tried a perspective from RessourcePermission.
EntityCollection<RessourcePermissionEntity> rpc = new EntityCollection<RessourcePermissionEntity>();
RelationPredicateBucket bucket = new RelationPredicateBucket();
bucket.Relations.Add(RessourcePermissionEntity.Relations.GroupEntityUsingGroupId);
bucket.Relations.Add(GroupEntity.Relations.MembershipEntityUsingGroupId);
bucket.Relations.Add(MembershipEntity.Relations.UserEntityUsingUserId);
bucket.PredicateExpression.Add(MembershipFields.UserId == "mos");
//Branch to user
IPrefetchPath2 pref = new PrefetchPath2(EntityType.RessourcePermissionEntity);
pref.Add(RessourcePermissionEntity.PrefetchPathGroup).SubPath.Add(GroupEntity.PrefetchPathUserCollectionViaMembership);
//Branch to project
pref.Add(RessourcePermissionEntity.PrefetchPathRessource).SubPath.Add(RessourceEntity.PrefetchPathProject);
DataAccessAdapter daa = new DataAccessAdapter();
daa.FetchEntityCollection(rpc, bucket, pref);
foreach (RessourcePermissionEntity rpe in rpc)
{
Debug.WriteLine(string.Format("{0} is member of group: {1} and has permission: {2} on project: {3}", rpe.Group.UserCollectionViaMembership[0].Name, rpe.Group.Name,
rpe.Permissions.ToString(), rpe.Ressource.Project.Name));
}
What happens, that I don't like, is that when I try to print out the rpe.Group.UserCollectionViaMembership[0].Name - of course it returns a list. It seems though that the collection in UserCollectionViaMembership has all users from same group as user "mos". I'd like it to have only users of "mos".
I hope someone is able to point me in the right direction or tell me what I have misunderstood