Example for Structured Exception Handling Public Function StructeddivideByVal a

Example for structured exception handling public

This preview shows page 48 - 50 out of 129 pages.

Example for Structured Exception Handling Public Function Structeddivide(ByVal a As Integer, ByVal b As Integer) As Integer Try Return a / b Catch ex As OverflowException MsgBox("Cannot divide by zero") Return -1 Finally MsgBox("Calculation over") End Try End Function New exception from SqlDataReader. In the System.Data.SqlClient namespace, you construct a SqlDataReader with code similar to this: Dim myCommand As New SqlCommand(mySelectQuery, myConnection) myConnection.Open() Dim myReader As SqlDataReader myReader = myCommand.ExecuteReader() In 1.0 this code would succeed, even if the command was chosen as the deadlock victim by SQL Server (in the case where there's a locking issue with another connection, of course). You wouldn't get a SqlException back until you actually tried to read data from the SqlDataReader. In 1.1 the ExecuteReader() method can now throw a SqlException. If you've got error handling that depends on only seeing this particular exception when you're actually reading data, you'll need to revise the code to move up. Question: 35 You are an application developer for your company, which is named Contoso, Ltd. You are developing an application that stores configuration data in a file named C:\Contoso\Persistence.config. This file is the only file your application will access. The design document for the application specifies the following two requirements: All authenticated users are allowed to view the contents of the configuration data file. Only members of a group named Managers are allowed to modify the data in the configuration data file. You need to ensure that the file can be accessed according to these requirements. Which two actions should you perform? (Each correct answer presents part of the solution. Choose two.) A. Apply a discretionary access control list (DACL) entry on the file. Use the DACL to grant Read permission to all authenticated users, and to grant Write permission to the Managers group. B. Apply a discretionary access control list (DACL) entry on the file. Use the DACL to grant Read permission to the Everyone group, and to grant Write permission to the Managers group. C. Add the following code segment to the application before accessing the file. Dim Wp As New WindowsPrincipal(WindowsIdentity.GetCurrent())Dim Manager As BooleanManager = Wp.IsInRole("Managers")Dim Fp As FileIOPermissionDim ConfigFile As StringConfigFile = "C:\Contoso\Persistence.config"If Manager Then Fp = New FileIOPermission(FileIOPermissionAccess.AllAccess, ConfigFile)Else Fp = New FileIOPermission(FileIOPermissionAccess.Read, ConfigFile)End IfFp.PermitOnly() D. Add the following code segment to the application before accessing the file. Dim Wp As New
Image of page 48
Exam Name: Implementing Security for Applications with Microsoft Visual Basic .NET Exam Type: Microsoft Exam Code: 70-330 Total Questions: 85 Page 49 of 129 WindowsPrincipal(WindowsIdentity.GetCurrent())If Wp.IsInRole("Managers") Then Dim Anon As WindowsIdentity Anon = WindowsIdentity.GetAnonymous() Anon.Impersonate()End If E. Require users to enter a password that is shared among members of the Managers group
Image of page 49
Image of page 50

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