LdapEncode Method

Microsoft AntiXSS Library

Collapse imageExpand ImageCopy imageCopyHover image
Encodes input strings to be used as a value in Lightweight Directory Access Protocol (LDAP) search queries.

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

Syntax

C#
[ObsoleteAttribute("This method has been deprecated. Please use Encoder.LdapFilterEncode() instead.")]
public static string LdapEncode(
	string input
)
Visual Basic
<ObsoleteAttribute("This method has been deprecated. Please use Encoder.LdapFilterEncode() instead.")> _
Public Shared Function LdapEncode ( _
	input As String _
) As String
Visual C++
[ObsoleteAttribute(L"This method has been deprecated. Please use Encoder.LdapFilterEncode() instead.")]
public:
static String^ LdapEncode(
	String^ input
)

Parameters

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

Return Value

Encoded string for use in LDAP search queries.

Remarks

This method encodes all but known safe characters defined in the safe list. RFC 4515 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. The following examples illustrate the use of the escaping mechanism.
Parens R Us (for all your parenthetical needs)Parens R Us \28for all your parenthetical needs\29
*\2A
C:\MyFileC:\5CMyFile
NULLNULLNULLEOT (binary)\00\00\00\04
LučićLu\C4\8Di\C4\87

See Also