C using System using using SystemThreading public class

C using system using using systemthreading public

This preview shows page 7 - 9 out of 129 pages.

[C#] using System; using System.Security.Principal; using System.Threading; public class Class1 { public static int Main(string[] args) { //Create generic identity. GenericIdentity MyIdentity = new GenericIdentity("MyIdentity"); //Create generic principal. String[] MyStringArray = {"Manager", "Teller"}; GenericPrincipal MyPrincipal = new GenericPrincipal(MyIdentity, MyStringArray); //Attach the principal to the current thread. //This is not required unless repeated validation must occur, //other code in your application must validate, or the
Image of page 7
Exam Name: Implementing Security for Applications with Microsoft Visual Basic .NET Exam Type: Microsoft Exam Code: 70-330 Total Questions: 85 Page 8 of 129 // PrincipalPermisson object is used. Thread.CurrentPrincipal = MyPrincipal; //Print values to the console. String Name = MyPrincipal.Identity.Name; bool Auth = MyPrincipal.Identity.IsAuthenticated; bool IsInRole = MyPrincipal.IsInRole("Manager"); Console.WriteLine("The Name is: {0}", Name); Console.WriteLine("The IsAuthenticated is: {0}", Auth); Console.WriteLine("Is this a Manager? {0}", IsInRole); return 0; } } Imports System Imports System.Security.Principal Imports System.Threading Public Class Class1 Public Shared Sub Main() 'Create generic identity. Dim MyIdentity As New GenericIdentity("MyIdentity") 'Create generic principal. Dim MyStringArray As String() = {"Manager", "Teller"} Dim MyPrincipal As New GenericPrincipal(MyIdentity, MyStringArray) 'Attach the principal to the current thread. 'This is not required unless repeated validation must occur, 'other code in your application must validate, or the ' PrincipalPermisson object is used. Thread.CurrentPrincipal = MyPrincipal 'Print values to the console. Dim Name As String = MyPrincipal.Identity.Name Dim Auth As Boolean = MyPrincipal.Identity.IsAuthenticated Dim IsInRole As Boolean = MyPrincipal.IsInRole("Manager") Console.WriteLine("The Name is: {0}", Name) Console.WriteLine("The IsAuthenticated is: {0}", Auth) Console.WriteLine("Is this a Manager? {0}", IsInRole) End Sub End Class When executed, the application displays output similar to the following. The Name is: MyIdentity The IsAuthenticated is: True Is this a Manager? True Question: 7 You are an application developer for your company. You are developing a three-tier Windows Forms application that will be used to manage confidential records. The business layer includes a remote object that is installed on an application server. The remote object is hosted in ASP.NET on the application server. IIS is configured to use Integrated Windows authentication, and ASP.NET is configured to use Windows authentication. All client computers and servers on the network support Kerberos authentication. The Windows Forms application communicates with the remote object by using a remoting proxy named myProxy. The remote object accesses a Microsoft SQL Server database. Permissions to database objects are granted based on the identity of the user. The remote object needs to run under the security context of the user. You need to write the code in the Windows Forms application that will configure the remoting proxy to have the credentials to use for authentication. Which code segment should you use?
Image of page 8
Image of page 9

You've reached the end of your free preview.

Want to read all 129 pages?

  • Spring '16
  • Microsoft Corporation, hash function, .NET Framework, Microsoft Visual Studio, Cryptographic hash function

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture