1.
You are developing a class library that will open the network socket connections to computers on the network.
You will deploy the class library to the global assembly cache and grant it full trust. You write the following code to ensure usage of the socket connections.
SocketPermission permission = new SocketPermission(PermissionState.Unrestricted); permission.Assert();
Some of the applications that use the class library might not have the necessary permissions to open the network socket connections. You need to cancel the assertion.
Which code segment should you use?
2.
You create a method that runs by using the credentials of the end user. You need to use Microsoft Windows groups to authorize the user. You must add a code segment that identifies whether a user is in the local group named Clerk.
Which code segment should you use?
3.
You need to write a code segment that performs the following tasks:
4.
You need to write a code segment that transfers the first 80 bytes from a stream variable named stream1 into a new byte array named byteArray. You also need to ensure that the code segment assigns the number of bytes
that are transferred to an integer variable named bytesTransferred.
Which code segment should you use?
5.
You are developing a fiscal report for a customer. Your customer has a main office in the United States and a satellite office in Mexico. You need to ensure that when users in the satellite office generate the report, the
current date is displayed in Mexican Spanish format. Which code segment should you use?
6.
You create an application that stores information about your customers who reside in various regions. You aredeveloping internal utilities for this application. You need to gather regional information about your customers in
Canada.
Which code segment should you use?
7.
You are developing a server application that will transmit sensitive information on a network. You create an X509Certificate object named certificate and a TcpClient object named client.
You need to create an SslStream to communicate by using the Transport Layer Security 1.0 protocol.
Which code segment should you use?
8.
You are writing a method that accepts a string parameter named message. Your method must break the message parameter into individual lines of text and pass each line to a second method named Process.
Which code segment should you use?
9.
You are developing a method to encrypt sensitive data with the Data Encryption Standard (DES) algorithm.
Your method accepts the following parameters:
10.
You are creating a new security policy for an application domain. You write the following lines of code.
PolicyLevel policy = PolicyLevel.CreateAppDomainLevel();
PolicyStatement noTrustStatement = new PolicyStatement(policy.
GetNamedPermissionSet("Nothing"));
PolicyStatement fullTrustStatement = new PolicyStatement(policy.
GetNamedPermissionSet("FullTrust"));
You need to arrange code groups for the policy so that loaded assemblies default to the Nothing permission set.
If the assembly originates from a trusted zone, the security policy must grant the assembly the FullTrust permission set. Which code segment should you use?