PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are developing an application that runs by using the credentials of the end user. Only users who are members of the Administrator group get permission to run the application. You write the following security code to protect sensitive data within the application.

Dim blnAdmin As Boolean = False
Dim objRole As WindowsBuiltInRole = _
WindowsBuiltInRole.Administrator
If blnAdmin = False Then
Throw New Exception(“User not permitted”)
End If

You need to add a code segment to this security code to ensure that the application throws an exception if a user is not a member of the Administrator group. Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Dim objUser As WindowsPrincipal = _DirectCast(Thread.CurrentPrincipal, WindowsPrincipal)blnAdmin = objUser.IsInRole(objRole)

B.
Dim objUser As WindowsIdentity = WindowsIdentity.GetCurrentFor Each objGroup As IdentityReference In objUser.GroupsDim objAccount As NTAccount = _ DirectCast(objGroup.Translate( _ Type.GetType(“NTAccount”)), NTAccount)blnAdmin = objGroup.Value.Equals(objRole)Next

C.
Dim objUser As GenericPrincipal = _DirectCast(Thread.CurrentPrincipal, GenericPrincipal)blnAdmin = objUser.IsInRole(objRole.ToString)

D.
Dim objUSer As WindowsIdentity = _DirectCast(Thread.CurrentPrincipal.Identity, WindowsIdentity)blnAdmin = objUSer.Name.EndsWith(“Administrator”)


Leave a Reply