Latest MCTS 70-536 Real Exam Download 31-40

Ensurepass

QUESTION 31

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?

A. CodeAccessPermission.RevertAssert();

B. CodeAccessPermission.RevertDeny();

C. permission.Deny();

D. permission.PermitOnly();

Correct Answer: A


QUESTION 32

You develop a service application named FileService. You deploy the service application to multiple servers on your network. You implement the following code

segment. (Line numbers are included for reference only.)

01: public void StartService(string serverName){ 02: ServiceController crtl = new

03: ServiceController("FileService"); 04: if (crtl.Status == ServiceControllerStatus.Stopped){ 05: }

06: }

You need to develop a routine that will start FileService if it stops. The routine must start FileService on the server identified by the serverName input parameter. Which two lines of code should you add to the code segment? (Each correct answer presents part of the solution. Choose two.)

A. Insert the following line of code between lines 03 and 04: crtl.ServiceName = serverName;

B. Insert the following line of code between lines 03 and 04: crtl.MachineName = serverName;

C. Insert the following line of code between lines 03 and 04: crtl.Site.Name = serverName;

D. Insert the following line of code between lines 04 and 05: crtl.Continue();

E. Insert the following line of code between lines 04 and 05: crtl.Start();

F. Insert the following line of code between lines 04 and 05: crtl.ExecuteCommand(0);

Correct Answer: BE


QUESTION 33

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?

A. WindowsIdentity currentUser = WindowsIdentity.GetCurrent(); foreach (IdentityReference grp in currentUser.Groups) {

NTAccount grpAccount = ((NTAccount)grp.Translate(typeof(NTAccount))); isAuthorized = grpAccount.Value.Equals(Environment.MachineName + @"\Clerk");

if(isAuthorized) break;

}

B. WindowsPrincipal currentUser = (WindowsPrincipal)Thread.CurrentPrincipal; isAuthorized = currentUser.IsInRole("Clerk");

C. GenericPrincipal currentUser = (GenericPrincipal) Thread.CurrentPrincipal; isAuthorized = currentUser.IsInRole("Clerk");

D. WindowsPrincipal currentUser = (WindowsPrincipal)Thread.CurrentPrincipal; isAuthorized = currentUser.IsInRole(Environment.MachineName);

Correct Answer: B


QUESTION 34

You need to write a code segment that performs the following tasks:

稲etrieve the name of each paused service.

稰asses the name of each paused service to the Add method of Collection1. Which code segment should you use?

A. ManagementObjectSearcher searcher =

new ManagementObjectSearcher("Select * from Win32_Service where State = ‘Paused’"); foreach (ManagementObject svc in searcher.Get())

{

Collection1.Add(svc["DisplayName"]);

}

B. ManagementObjectSearcher searcher =

new ManagementObjectSearcher("Select * from Win32_Service", "State =’Paused’"); foreach (ManagementObject svc in searcher.Get())

{

Collection1.Add(svc["DisplayName"]);

}

C. ManagementObjectSearcher searcher =

new ManagementObjectSearcher("Select * from Win32_Service"); foreach (ManagemetnObject svc in searcher.Get())

{

if ((string) svc["State"] == "’Paused’")

{

Collection1.Add(svc["DisplayName"]);

}

}

D. ManagementObjectSearcher searcher = new ManagementObjectSearcher(); searcher.Scope = new ManagementScope("Win32_Service"); foreach (ManagementObject svc in searcher.Get())

{

if ((string)svc["State"] == "Paused")

{

Collection1.Add(svc["DisplayName"]);

}

}

Correct Answer: A


QUESTION 35

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?

A. bytesTransferred = stream1.Read(byteArray, 0, 80);

B. for (int i = 0; i < 80; i++)

{

stream1.WriteByte(byteArray[i]); bytesTransferred = i;

if (!stream1.CanWrite)

{

break;

}

}

C. while (bytesTransferred < 80)

{

stream1.Seek(1, SeekOrigin.Current);

byteArray[bytesTransferred++] = Convert.ToByte(stream1.ReadByte()); }

D. stream1.Write(byteArray, 0, 80); bytesTransferred = byteArray.Length;

Correct Answer: A


QUESTION 36

You create an application that stores information about your customers who reside in various regions. You are developing internal utilities for this application. You need to gather regional information about your customers in Canada.

Which code segment should you use?

A. foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) {

// Output the region information…

}

B. CultureInfo cultureInfo = new CultureInfo("CA");

// Output the region information…

C. RegionInfo regionInfo = new RegionInfo("CA");

// Output the region information…

D. RegionInfo regionInfo = new RegionInfo(""); if(regionInfo.Name == "CA")

{

// Output the region information…

}

Correct Answer: C


QUESTION 37

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?

A. SslStream ssl = new SslStream(client.GetStream()); ssl.AuthenticateAsServer(certificate,false, SslProtocols.None, true);

B. SslStream ssl = new SslStream(client.GetStream()); ssl.AuthenticateAsServer(certificate,false, SslProtocols.Ssl3, true);

C. SslStream ssl = new SslStream(client.GetStream()); ssl.AuthenticateAsServer(certificate,false, SslProtocols.Ssl2, true);

D. SslStream ssl = new SslStream(client.GetStream()); ssl.AuthenticateAsServer(certificate,false, SslProtocols.Tls, true);

Correct Answer: D


QUESTION 38

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?

A. StringReader reader = new StringReader(message); Process(reader.ReadToEnd());

reader.Close();

B. StringReader reader = new StringReader(message); while (reader.Peek() != -1)

{

string line = reader.Read().ToString(); Process(line);

}

reader.Close();

C. StringReader reader = new StringReader(message); Process(reader.ToString());

reader.Close();

D. StringReader reader = new StringReader(message); while (reader.Peek() != -1)

{

Process(reader.ReadLine());

}

reader.Close();

Correct Answer: D


QUESTION 39

You are developing a method to encrypt sensitive data with the Data Encryption Standard (DES) algorithm. Your method accepts the following parameters:

稵he byte array to be encrypted, which is named message

稟n encryption key, which is named key

稟n initialization vector, which is named iv

You need to encrypt the data. You also need to write the encrypted data to a MemoryStream object. Which code segment should you use?

A. DES des = new DESCryptoServiceProvider(); des.BlockSize = message.Length;

ICryptoTransform crypto = des.CreateEncryptor(key, iv); MemoryStream cipherStream = new MemoryStream();

CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write); cryptoStream.Write(message, 0, message.Length);

B. DES des = new DESCryptoServiceProvider(); ICryptoTransform crypto = des.CreateDecryptor(iv, key); MemoryStream cipherStream = new MemoryStream();

CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write); cryptoStream.Write(message, 0, message.Length);

C. DES des = new DESCryptoServiceProvider(); ICryptoTransform crypto = des.CreateEncryptor(); MemoryStream cipherStream = new MemoryStream();

CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write); cryptoStream.Write(message, 0, message.Length);

D. DES des = new DESCryptoServiceProvider(); ICryptoTransform crypto = des.CreateEncryptor(key, iv); MemoryStream cipherStream = new MemoryStream();

CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write); cryptoStream.Write(message, 0, message.Length);

Correct Answer: D


QUESTION 40

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?

A. CodeGroup group1 = new FirstMatchCodeGroup(new AllMembershipCondition(), noTrustStatement); CodeGroup group2 = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Trusted), fullTrustStatement);

group1.AddChild(group2);

B. CodeGroup group = new FirstMatchCodeGroup(new AllMembershipCondition(), noTrustStatement);

C. CodeGroup group = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Trusted), fullTrustStatement);

D. CodeGroup group1 = new FirstMatchCodeGroup(new ZoneMembershipCondition(SecurityZone.

Trusted), fullTrustStatement);

CodeGroup group2 = new UnionCoderoup(new AllMembershipCondition(), noTrustStatement); group1.AddChild(group2);

Correct Answer: A

Download Latest 70-536 Real Free Tests , help you to pass exam 100%.