I have just upgraded from 7.5.9 to 7.7 and see where the umbracoUserType and umbracoUser2app tables have been replaced with umbracoUserGroup and umbracoUser2UserGroup, which is fine.
But for me, I need to insert/delete into this table based on what the user has in Active Directory.
I could use Entity Framework to do my work but wanted to make sure I wasn't missing anything by not using the Umbraco UserService object.
I did find a userService.AddGroup() but its read only.
Question: Is there an Umbraco object API call that will allow me to add a group to an existing user?
You can easily add Groups to User with AddGroup function of IUser.
For example:
public void MakeAdmin (IUser user)
{
IUserService _userService = ApplicationContext.Current.Services.UserService;
// how to remove a group from user
user.RemoveGroup("writerAlias");
// get Admin group
var adminGroup = _userService.GetUserGroupByAlias("adminAlias") as IReadOnlyUserGroup;
// how to add a group to user
user.AddGroup(adminGroup);
// save user
_userService.Save(user);
}
How to Add a group to a User
I have just upgraded from 7.5.9 to 7.7 and see where the umbracoUserType and umbracoUser2app tables have been replaced with umbracoUserGroup and umbracoUser2UserGroup, which is fine.
But for me, I need to insert/delete into this table based on what the user has in Active Directory.
I could use Entity Framework to do my work but wanted to make sure I wasn't missing anything by not using the Umbraco UserService object. I did find a userService.AddGroup() but its read only.
Question: Is there an Umbraco object API call that will allow me to add a group to an existing user?
Thanks
Tom
Hii,
You can easily add Groups to User with AddGroup function of IUser.
For example:
is working on a reply...