How to escape a string in C#, for use in an LDAP query

前端 未结 6 632
囚心锁ツ
囚心锁ツ 2020-12-14 10:00

I have an LDAP query, which I am using to perform a search in C#. It uses two string variables (username and domain) which need to be escaped for security reasons.

H

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-14 10:14

    Use AntiXss library from address: https://www.nuget.org/packages/AntiXss

    string encoded = Microsoft.Security.Application.Encoder.LdapFilterEncode(input);
    

提交回复
热议问题