rspec/rules/S4433/csharp/rule.adoc
2020-06-30 17:16:12 +02:00

22 lines
815 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
This rule raises an issue when an LDAP connection is created with <code>AuthenticationTypes.Anonymous</code> or <code>AuthenticationTypes.None</code>.
----
DirectoryEntry myDirectoryEntry = new DirectoryEntry(adPath);
myDirectoryEntry.AuthenticationType = AuthenticationTypes.None; // Noncompliant
DirectoryEntry myDirectoryEntry = new DirectoryEntry(adPath, "u", "p", AuthenticationTypes.None); // Noncompliant
----
== Compliant Solution
----
DirectoryEntry myDirectoryEntry = new DirectoryEntry(myADSPath); // Compliant; default DirectoryEntry.AuthenticationType property value is "Secure" since .NET Framework 2.0
DirectoryEntry myDirectoryEntry = new DirectoryEntry(myADSPath, "u", "p", AuthenticationTypes.Secure);
----
include::../see.adoc[]