LdapDistinguishedNameEncode Method (String)

Microsoft AntiXSS Library

Collapse imageExpand ImageCopy imageCopyHover image
Encodes input strings for use as a value in Lightweight Directory Access Protocol (LDAP) DNs.

Namespace: Microsoft.Security.Application
Assembly: AntiXssLibrary40 (in AntiXssLibrary40.dll) Version: 4.2.0.0

Syntax

C#
public static string LdapDistinguishedNameEncode(
	string input
)
Visual Basic
Public Shared Function LdapDistinguishedNameEncode ( _
	input As String _
) As String
Visual C++
public:
static String^ LdapDistinguishedNameEncode(
	String^ input
)

Parameters

input
Type: System..::..String
String to be encoded.

Return Value

Encoded string for use as a value in LDAP DNs.

Remarks

This method encodes all but known safe characters defined in the safe list. RFC 2253 defines the format in which special characters need to be escaped to be used inside a search filter. Special characters need to be encoded in #XX format where XX is the hex representation of the character or a specific \ escape format. The following examples illustrate the use of the escaping mechanism.
, + \ " \ < >\, \+ \" \\ \< \>
hello\ hello
hello hello \
#hello\#hello
LučićLu#C4#8Di#C4#87

See Also