best example is in _layouts/aclinv.aspx
- this page uses a PeopleEditor control called userPicker
to have a look at the codebehind:
-> open "Microsoft.SharePoint.ApplicationPages.dll" in Lutz Roeder's .NET Reflector
-> Go to "Microsoft.SharePoint.ApplicationPages.AclInv"
-> Check out "public void BtnOK_Click(object sender, EventArgs e);"
this event adds users chosen in the PeopleEditor to a group or direclty grants them permissions.
What it does is:
-> Iterate through this.userPicker.ResolvedEntities, map to an array of SPUserInfo[];
-> Like so:
PickerEntity entity2 = (PickerEntity) this.userPicker.ResolvedEntities[index];
SPUserInfo info = new SPUserInfo();
info.LoginName = entity2.Key;
info.Email = (string) entity2.EntityData[PeopleEditor.PeopleInfo.Email];
info.Name = entity2.DisplayText;
info.Notes = string.Empty;
addUsersInfo[index] = info;
-> then add that to a group like so: this.ReferencedGroups.GetByID(int.Parse(this.DdlGroup.SelectedValue)).Users.AddCollection(addUsersInfo);