The ensureuser method adds the
string loginName = "Domain\User_Alias";
string grpName = "Group1";
//EnsureUser - Checks whether the specified logon name belongs to a valid user of the website, and if the logon name does not already exist, adds it to the website.
SPUser user = SPContext.Current.Web.EnsureUser(loginName);
SPGroup group = SPContext.Current.Web.Groups[grpName];
//Add the user to the Group
group.AddUser(user);
group.Update();
3 comments:
Thanks a lot for this post
Thanks a Lot fot his post
Thanks a lot for this
Post a Comment