Which code condition should you use?

You need to create a Web Part that verifies whether a user who accesses the Web Part page is a member of a group named Group1.

Which code condition should you use?

You need to create a Web Part that verifies whether a user who accesses the Web Part page is a member of a group named Group1.

Which code condition should you use?

A.
SPContext.Current.Web.Groups[“Group1”].ContainsCurrentUser;

B.
SPContext.Current.Web.SiteUsers[SPContext.Current.Web.CurrentUser.ID].Groups[“Group1”] != null;

C.
SPContext.Current.Web.SiteUsers[SPContext.Current.Web.CurrentUser.ID].Groups[“Group1”] == null;

D.
SPContext.Current.Web.Users[“Group1”].IsDomainGroup;

Explanation:
MNEMONIC RULE: ContainsCurrentUser

Gets a Boolean value that indicates whether the group contains the current user, included either through direct or indirect membership.

SPGroup.ContainsCurrentUser Property
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spgroup.containscurrentuser.aspx



Leave a Reply 0

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