rspec/rules/S4433/csharp/rule.adoc

23 lines
806 B
Plaintext
Raw Normal View History

2020-06-30 12:49:37 +02:00
include::../description.adoc[]
== Noncompliant Code Example
2021-01-27 13:42:22 +01:00
This rule raises an issue when an LDAP connection is created with ``++AuthenticationTypes.Anonymous++`` or ``++AuthenticationTypes.None++``.
2020-06-30 12:49:37 +02:00
----
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[]