Skip to main content


 

Symptoms


Dears,
we have a problem with K2 API while adding a Role Member through SourceCode APIs, here is the scenario
1- I add the user to the Role through API and It works fine
Role.Include.Add(new UserItem(@"K2:" Username))
2- Remove the user from the Role through API ( It Unchecked the Include attribute) and It works fine
Role.Exclude.Add(new UserItem(@"K2:" Username))
3- Now, try to add the user again through API, It does not work and the user still have Include attribute unchecked
Role.Include.Add(new UserItem(@"K2:" Username))


 

Diagnoses


Similar code to this was supplied to the customer to remove the user completely from the Role

string remUser="K2:DomainUser"

foreach (RoleItem ri in role.Include)
{
if (ri.Name.ToLower() == remUser.ToLower())
{
role.Include.Remove(ri)
break
}
}

foreach (RoleItem ri in role.Exclude)
{
if (ri.Name.ToLower() == remUser.ToLower())
{
role.Exclude.Remove(ri)
break
}
}
 

Resolution

Similar code to this was supplied to the customer to remove the user completely from the Role

string remUser="K2:DomainUser"

foreach (RoleItem ri in role.Include)
{
if (ri.Name.ToLower() == remUser.ToLower())
{
role.Include.Remove(ri)
break
}
}

foreach (RoleItem ri in role.Exclude)
{
if (ri.Name.ToLower() == remUser.ToLower())
{
role.Exclude.Remove(ri)
break
}
}


IMPORTANT:
In K2 4.7 this will change and this code will not run




 
Be the first to reply!

Reply