Which code segment should you add at line 05?

You need to programmatically add a user named User1 to a group named Group1.

You write the following code segment. (Line numbers are included for reference only.)

01 string login = “User1”;
02 string grpName = “Group1”;
03 SPUser user = SPContext.Current.Web.EnsureUser(login);
04 SPGroup group = SPContext.Current.Web.Groups[grpName];
05
06 group.Update();

Which code segment should you add at line 05?

You need to programmatically add a user named User1 to a group named Group1.

You write the following code segment. (Line numbers are included for reference only.)

01 string login = “User1”;
02 string grpName = “Group1”;
03 SPUser user = SPContext.Current.Web.EnsureUser(login);
04 SPGroup group = SPContext.Current.Web.Groups[grpName];
05
06 group.Update();

Which code segment should you add at line 05?

A.
group.AddUser(user);

B.
group.Owner = user;

C.
user.AllowBrowseUserInfo = true;

D.
user.Update();

Explanation:
MNEMONIC RULE: “add a user = AddUser()”

SPGroup.AddUser Method
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spgroup.adduser.aspx



Leave a Reply 0

Your email address will not be published. Required fields are marked *