which the roryallen user account is a member.What code segment should you use?

You have developed a Web application for Domain.com’s existing Web site. The Web application implements role-based security to allow for the administration and maintenance of the Domain.com Web site. It allows certain users to administer the Web site, including the databases used by the Web site, while others are allowed to a maintain the Web site by adding and editing product information. Only Web administrators should be able to manually add users to the Web application. You discover that a user named Rory Allen has added a user account to the Web site. You also suspect that he has added his user account to various roles. You want to retrieve a list of the role of which the roryallen user account is a member.
What code segment should you use?

You have developed a Web application for Domain.com’s existing Web site. The Web application implements role-based security to allow for the administration and maintenance of the Domain.com Web site. It allows certain users to administer the Web site, including the databases used by the Web site, while others are allowed to a maintain the Web site by adding and editing product information. Only Web administrators should be able to manually add users to the Web application. You discover that a user named Rory Allen has added a user account to the Web site. You also suspect that he has added his user account to various roles. You want to retrieve a list of the role of which the roryallen user account is a member.
What code segment should you use?

A.
string[] roles = Roles.GetRolesForUser("roryallen");

B.
string[] roles = Roles.FindUsersInRole("roryallen");

C.
string[] roles = Roles.FindUsersInRole("","roryallen");

D.
string[] roles = Roles.GetAllRoles();

Explanation:
The GetRolesForUser method of Roles returns a list of roles of which the specified user is a member.

Incorrect Answers:
B: The FindUsersInRole method requires two parameters – the role and the user account.
C: The FindUsersInRole method requires two parameters – the role and the user account. This code will return a list of users named roryallen in an empty role.
D: The GetAllRoles method returns a list of roles supported by the role provider.



Leave a Reply 0

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