Which code segment should you use?

You are creating an XML Web service named ViewOrders that is available to customers over the Internet. ViewOrders exposes a Web method named ViewShippingDetail that requires additional security. You decide to use generic role-based security to secure ViewShippingDetail. You need to write code to ensure that once the caller is authenticated, a user identity named Generic is created. This user identity has membership in a group named Shipping to allow access to ViewShippingDetail.

Which code segment should you use?

You are creating an XML Web service named ViewOrders that is available to customers over the Internet. ViewOrders exposes a Web method named ViewShippingDetail that requires additional security. You decide to use generic role-based security to secure ViewShippingDetail. You need to write code to ensure that once the caller is authenticated, a user identity named Generic is created. This user identity has membership in a group named Shipping to allow access to ViewShippingDetail.

Which code segment should you use?

A.
System.Security.Principal.IIdentity myIdentity = new
GenericIdentity(“Generic”, “Custom”);
string[] Roles = {“Shipping”};
GenericPrincipal myPrincipal = new GenericPrincipal(myIdentity, Roles); myIdentity = WindowsIdentity.GetCurrent();

B.
GenericIdentity myIdentity = new
GenericIdentity(“Generic”, “Custom”);
string[] Roles = {“Shipping”};
GenericPrincipal myPrincipal = new
GenericPrincipal(myIdentity, Roles);
Thread.CurrentPrincipal = myPrincipal;

C.
IIdentity myIdentity = new
GenericIdentity(“Generic”, “Shipping”);
IPrincipal myPrincipal = new
WindowsPrincipal((WindowsIdentity) myIdentity);
Thread.CurrentPrincipal = myPrincipal;

D.
IIdentity myGenericIdent = new
GenericIdentity(“Generic”, “Custom”);
WindowsIdentity myIdentity = (WindowsIdentity) myGenericIdent; string[] Roles = {“Shipping”};
GenericPrincipal myPrincipal = new
GenericPrincipal(myIdentity, Roles);
WindowsIdentity.Impersonate(myIdentity.Token);



Leave a Reply 0

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