1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Runtime.InteropServices; 6 using System.Security; 7 8 namespace System.DirectoryServices.Protocols 9 { 10 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 11 internal class Luid 12 { 13 private int _lowPart; 14 private int _highPart; 15 16 public int LowPart => _lowPart; 17 public int HighPart => _highPart; 18 } 19 20 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 21 internal sealed class SEC_WINNT_AUTH_IDENTITY_EX 22 { 23 public int version; 24 public int length; 25 public string user; 26 public int userLength; 27 public string domain; 28 public int domainLength; 29 public string password; 30 public int passwordLength; 31 public int flags; 32 public string packageList; 33 public int packageListLength; 34 } 35 36 internal enum BindMethod : uint 37 { 38 LDAP_AUTH_OTHERKIND = 0x86, 39 LDAP_AUTH_SICILY = LDAP_AUTH_OTHERKIND | 0x0200, 40 LDAP_AUTH_MSN = LDAP_AUTH_OTHERKIND | 0x0800, 41 LDAP_AUTH_NTLM = LDAP_AUTH_OTHERKIND | 0x1000, 42 LDAP_AUTH_DPA = LDAP_AUTH_OTHERKIND | 0x2000, 43 LDAP_AUTH_NEGOTIATE = LDAP_AUTH_OTHERKIND | 0x0400, 44 LDAP_AUTH_SSPI = LDAP_AUTH_NEGOTIATE, 45 LDAP_AUTH_DIGEST = LDAP_AUTH_OTHERKIND | 0x4000, 46 LDAP_AUTH_EXTERNAL = LDAP_AUTH_OTHERKIND | 0x0020 47 } 48 49 internal enum LdapOption 50 { 51 LDAP_OPT_DESC = 0x01, 52 LDAP_OPT_DEREF = 0x02, 53 LDAP_OPT_SIZELIMIT = 0x03, 54 LDAP_OPT_TIMELIMIT = 0x04, 55 LDAP_OPT_REFERRALS = 0x08, 56 LDAP_OPT_RESTART = 0x09, 57 LDAP_OPT_SSL = 0x0a, 58 LDAP_OPT_REFERRAL_HOP_LIMIT = 0x10, 59 LDAP_OPT_VERSION = 0x11, 60 LDAP_OPT_API_FEATURE_INFO = 0x15, 61 LDAP_OPT_HOST_NAME = 0x30, 62 LDAP_OPT_ERROR_NUMBER = 0x31, 63 LDAP_OPT_ERROR_STRING = 0x32, 64 LDAP_OPT_SERVER_ERROR = 0x33, 65 LDAP_OPT_SERVER_EXT_ERROR = 0x34, 66 LDAP_OPT_HOST_REACHABLE = 0x3E, 67 LDAP_OPT_PING_KEEP_ALIVE = 0x36, 68 LDAP_OPT_PING_WAIT_TIME = 0x37, 69 LDAP_OPT_PING_LIMIT = 0x38, 70 LDAP_OPT_DNSDOMAIN_NAME = 0x3B, 71 LDAP_OPT_GETDSNAME_FLAGS = 0x3D, 72 LDAP_OPT_PROMPT_CREDENTIALS = 0x3F, 73 LDAP_OPT_TCP_KEEPALIVE = 0x40, 74 LDAP_OPT_FAST_CONCURRENT_BIND = 0x41, 75 LDAP_OPT_SEND_TIMEOUT = 0x42, 76 LDAP_OPT_REFERRAL_CALLBACK = 0x70, 77 LDAP_OPT_CLIENT_CERTIFICATE = 0x80, 78 LDAP_OPT_SERVER_CERTIFICATE = 0x81, 79 LDAP_OPT_AUTO_RECONNECT = 0x91, 80 LDAP_OPT_SSPI_FLAGS = 0x92, 81 LDAP_OPT_SSL_INFO = 0x93, 82 LDAP_OPT_SIGN = 0x95, 83 LDAP_OPT_ENCRYPT = 0x96, 84 LDAP_OPT_SASL_METHOD = 0x97, 85 LDAP_OPT_AREC_EXCLUSIVE = 0x98, 86 LDAP_OPT_SECURITY_CONTEXT = 0x99, 87 LDAP_OPT_ROOTDSE_CACHE = 0x9a 88 } 89 90 internal enum ResultAll 91 { 92 LDAP_MSG_ALL = 1, 93 LDAP_MSG_RECEIVED = 2, 94 LDAP_MSG_POLLINGALL = 3 95 } 96 97 [StructLayout(LayoutKind.Sequential)] 98 internal sealed class LDAP_TIMEVAL 99 { 100 public int tv_sec; 101 public int tv_usec; 102 } 103 104 [StructLayout(LayoutKind.Sequential)] 105 internal sealed class berval 106 { 107 public int bv_len = 0; 108 public IntPtr bv_val = IntPtr.Zero; 109 berval()110 public berval() { } 111 } 112 113 [StructLayout(LayoutKind.Sequential)] 114 internal sealed class SafeBerval 115 { 116 public int bv_len = 0; 117 public IntPtr bv_val = IntPtr.Zero; 118 ~SafeBerval()119 ~SafeBerval() 120 { 121 if (bv_val != IntPtr.Zero) 122 { 123 Marshal.FreeHGlobal(bv_val); 124 } 125 } 126 } 127 128 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 129 internal sealed class LdapControl 130 { 131 public IntPtr ldctl_oid = IntPtr.Zero; 132 public berval ldctl_value = null; 133 public bool ldctl_iscritical = false; 134 LdapControl()135 public LdapControl() { } 136 } 137 138 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 139 internal struct LdapReferralCallback 140 { 141 public int sizeofcallback; 142 public QUERYFORCONNECTIONInternal query; 143 public NOTIFYOFNEWCONNECTIONInternal notify; 144 public DEREFERENCECONNECTIONInternal dereference; 145 } 146 147 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 148 internal struct CRYPTOAPI_BLOB 149 { 150 public int cbData; 151 public IntPtr pbData; 152 } 153 154 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 155 internal struct SecPkgContext_IssuerListInfoEx 156 { 157 public IntPtr aIssuers; 158 public int cIssuers; 159 } 160 161 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 162 internal sealed class LdapMod 163 { 164 public int type = 0; 165 public IntPtr attribute = IntPtr.Zero; 166 public IntPtr values = IntPtr.Zero; 167 ~LdapMod()168 ~LdapMod() 169 { 170 if (attribute != IntPtr.Zero) 171 { 172 Marshal.FreeHGlobal(attribute); 173 } 174 175 if (values != IntPtr.Zero) 176 { 177 Marshal.FreeHGlobal(values); 178 } 179 } 180 } 181 182 internal class Wldap32 183 { 184 private const string Wldap32dll = "wldap32.dll"; 185 186 public const int SEC_WINNT_AUTH_IDENTITY_UNICODE = 0x2; 187 public const int SEC_WINNT_AUTH_IDENTITY_VERSION = 0x200; 188 public const string MICROSOFT_KERBEROS_NAME_W = "Kerberos"; 189 190 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_bind_sW", CharSet = CharSet.Unicode)] ldap_bind_s([In]ConnectionHandle ldapHandle, string dn, SEC_WINNT_AUTH_IDENTITY_EX credentials, BindMethod method)191 public static extern int ldap_bind_s([In]ConnectionHandle ldapHandle, string dn, SEC_WINNT_AUTH_IDENTITY_EX credentials, BindMethod method); 192 193 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_initW", SetLastError = true, CharSet = CharSet.Unicode)] ldap_init(string hostName, int portNumber)194 public static extern IntPtr ldap_init(string hostName, int portNumber); 195 196 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, EntryPoint = "ldap_connect", CharSet = CharSet.Unicode)] ldap_connect([In] ConnectionHandle ldapHandle, LDAP_TIMEVAL timeout)197 public static extern int ldap_connect([In] ConnectionHandle ldapHandle, LDAP_TIMEVAL timeout); 198 199 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, EntryPoint = "ldap_unbind", CharSet = CharSet.Unicode)] ldap_unbind([In] IntPtr ldapHandle)200 public static extern int ldap_unbind([In] IntPtr ldapHandle); 201 202 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_get_optionW", CharSet = CharSet.Unicode)] ldap_get_option_int([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref int outValue)203 public static extern int ldap_get_option_int([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref int outValue); 204 205 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)] ldap_set_option_int([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref int inValue)206 public static extern int ldap_set_option_int([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref int inValue); 207 208 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_get_optionW", CharSet = CharSet.Unicode)] ldap_get_option_ptr([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref IntPtr outValue)209 public static extern int ldap_get_option_ptr([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref IntPtr outValue); 210 211 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)] ldap_set_option_ptr([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref IntPtr inValue)212 public static extern int ldap_set_option_ptr([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref IntPtr inValue); 213 214 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_get_optionW", CharSet = CharSet.Unicode)] ldap_get_option_sechandle([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref SecurityHandle outValue)215 public static extern int ldap_get_option_sechandle([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref SecurityHandle outValue); 216 217 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_get_optionW", CharSet = CharSet.Unicode)] ldap_get_option_secInfo([In] ConnectionHandle ldapHandle, [In] LdapOption option, [In, Out] SecurityPackageContextConnectionInformation outValue)218 public static extern int ldap_get_option_secInfo([In] ConnectionHandle ldapHandle, [In] LdapOption option, [In, Out] SecurityPackageContextConnectionInformation outValue); 219 220 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)] ldap_set_option_referral([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref LdapReferralCallback outValue)221 public static extern int ldap_set_option_referral([In] ConnectionHandle ldapHandle, [In] LdapOption option, ref LdapReferralCallback outValue); 222 223 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)] ldap_set_option_clientcert([In] ConnectionHandle ldapHandle, [In] LdapOption option, QUERYCLIENTCERT outValue)224 public static extern int ldap_set_option_clientcert([In] ConnectionHandle ldapHandle, [In] LdapOption option, QUERYCLIENTCERT outValue); 225 226 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_set_optionW", CharSet = CharSet.Unicode)] ldap_set_option_servercert([In] ConnectionHandle ldapHandle, [In] LdapOption option, VERIFYSERVERCERT outValue)227 public static extern int ldap_set_option_servercert([In] ConnectionHandle ldapHandle, [In] LdapOption option, VERIFYSERVERCERT outValue); 228 229 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "LdapGetLastError")] LdapGetLastError()230 public static extern int LdapGetLastError(); 231 232 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "cldap_openW", SetLastError = true, CharSet = CharSet.Unicode)] cldap_open(string hostName, int portNumber)233 public static extern IntPtr cldap_open(string hostName, int portNumber); 234 235 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_simple_bind_sW", CharSet = CharSet.Unicode)] ldap_simple_bind_s([In] ConnectionHandle ldapHandle, string distinguishedName, string password)236 public static extern int ldap_simple_bind_s([In] ConnectionHandle ldapHandle, string distinguishedName, string password); 237 238 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_delete_extW", CharSet = CharSet.Unicode)] ldap_delete_ext([In] ConnectionHandle ldapHandle, string dn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber)239 public static extern int ldap_delete_ext([In] ConnectionHandle ldapHandle, string dn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); 240 241 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_result", SetLastError = true, CharSet = CharSet.Unicode)] ldap_result([In] ConnectionHandle ldapHandle, int messageId, int all, LDAP_TIMEVAL timeout, ref IntPtr Mesage)242 public static extern int ldap_result([In] ConnectionHandle ldapHandle, int messageId, int all, LDAP_TIMEVAL timeout, ref IntPtr Mesage); 243 244 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_parse_resultW", CharSet = CharSet.Unicode)] ldap_parse_result([In] ConnectionHandle ldapHandle, [In] IntPtr result, ref int serverError, ref IntPtr dn, ref IntPtr message, ref IntPtr referral, ref IntPtr control, byte freeIt)245 public static extern int ldap_parse_result([In] ConnectionHandle ldapHandle, [In] IntPtr result, ref int serverError, ref IntPtr dn, ref IntPtr message, ref IntPtr referral, ref IntPtr control, byte freeIt); 246 247 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_parse_resultW", CharSet = CharSet.Unicode)] ldap_parse_result_referral([In] ConnectionHandle ldapHandle, [In] IntPtr result, IntPtr serverError, IntPtr dn, IntPtr message, ref IntPtr referral, IntPtr control, byte freeIt)248 public static extern int ldap_parse_result_referral([In] ConnectionHandle ldapHandle, [In] IntPtr result, IntPtr serverError, IntPtr dn, IntPtr message, ref IntPtr referral, IntPtr control, byte freeIt); 249 250 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_memfreeW", CharSet = CharSet.Unicode)] ldap_memfree([In] IntPtr value)251 public static extern void ldap_memfree([In] IntPtr value); 252 253 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_value_freeW", CharSet = CharSet.Unicode)] ldap_value_free([In] IntPtr value)254 public static extern int ldap_value_free([In] IntPtr value); 255 256 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_controls_freeW", CharSet = CharSet.Unicode)] ldap_controls_free([In] IntPtr value)257 public static extern int ldap_controls_free([In] IntPtr value); 258 259 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_abandon", CharSet = CharSet.Unicode)] ldap_abandon([In] ConnectionHandle ldapHandle, [In] int messagId)260 public static extern int ldap_abandon([In] ConnectionHandle ldapHandle, [In] int messagId); 261 262 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_start_tls_sW", CharSet = CharSet.Unicode)] ldap_start_tls(ConnectionHandle ldapHandle, ref int ServerReturnValue, ref IntPtr Message, IntPtr ServerControls, IntPtr ClientControls)263 public static extern int ldap_start_tls(ConnectionHandle ldapHandle, ref int ServerReturnValue, ref IntPtr Message, IntPtr ServerControls, IntPtr ClientControls); 264 265 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_stop_tls_s", CharSet = CharSet.Unicode)] ldap_stop_tls(ConnectionHandle ldapHandle)266 public static extern byte ldap_stop_tls(ConnectionHandle ldapHandle); 267 268 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_rename_extW", CharSet = CharSet.Unicode)] ldap_rename([In] ConnectionHandle ldapHandle, string dn, string newRdn, string newParentDn, int deleteOldRdn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber)269 public static extern int ldap_rename([In] ConnectionHandle ldapHandle, string dn, string newRdn, string newParentDn, int deleteOldRdn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); 270 271 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_compare_extW", CharSet = CharSet.Unicode)] ldap_compare([In] ConnectionHandle ldapHandle, string dn, string attributeName, string strValue, berval binaryValue, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber)272 public static extern int ldap_compare([In] ConnectionHandle ldapHandle, string dn, string attributeName, string strValue, berval binaryValue, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); 273 274 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_add_extW", CharSet = CharSet.Unicode)] ldap_add([In] ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber)275 public static extern int ldap_add([In] ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); 276 277 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_modify_extW", CharSet = CharSet.Unicode)] ldap_modify([In] ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber)278 public static extern int ldap_modify([In] ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); 279 280 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_extended_operationW", CharSet = CharSet.Unicode)] ldap_extended_operation([In] ConnectionHandle ldapHandle, string oid, berval data, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber)281 public static extern int ldap_extended_operation([In] ConnectionHandle ldapHandle, string oid, berval data, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); 282 283 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_parse_extended_resultW", CharSet = CharSet.Unicode)] ldap_parse_extended_result([In] ConnectionHandle ldapHandle, [In] IntPtr result, ref IntPtr oid, ref IntPtr data, byte freeIt)284 public static extern int ldap_parse_extended_result([In] ConnectionHandle ldapHandle, [In] IntPtr result, ref IntPtr oid, ref IntPtr data, byte freeIt); 285 286 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_msgfree", CharSet = CharSet.Unicode)] ldap_msgfree([In] IntPtr result)287 public static extern int ldap_msgfree([In] IntPtr result); 288 289 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_search_extW", CharSet = CharSet.Unicode)] ldap_search([In] ConnectionHandle ldapHandle, string dn, int scope, string filter, IntPtr attributes, bool attributeOnly, IntPtr servercontrol, IntPtr clientcontrol, int timelimit, int sizelimit, ref int messageNumber)290 public static extern int ldap_search([In] ConnectionHandle ldapHandle, string dn, int scope, string filter, IntPtr attributes, bool attributeOnly, IntPtr servercontrol, IntPtr clientcontrol, int timelimit, int sizelimit, ref int messageNumber); 291 292 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_first_entry", CharSet = CharSet.Unicode)] ldap_first_entry([In] ConnectionHandle ldapHandle, [In] IntPtr result)293 public static extern IntPtr ldap_first_entry([In] ConnectionHandle ldapHandle, [In] IntPtr result); 294 295 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_next_entry", CharSet = CharSet.Unicode)] ldap_next_entry([In] ConnectionHandle ldapHandle, [In] IntPtr result)296 public static extern IntPtr ldap_next_entry([In] ConnectionHandle ldapHandle, [In] IntPtr result); 297 298 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_first_reference", CharSet = CharSet.Unicode)] ldap_first_reference([In] ConnectionHandle ldapHandle, [In] IntPtr result)299 public static extern IntPtr ldap_first_reference([In] ConnectionHandle ldapHandle, [In] IntPtr result); 300 301 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_next_reference", CharSet = CharSet.Unicode)] ldap_next_reference([In] ConnectionHandle ldapHandle, [In] IntPtr result)302 public static extern IntPtr ldap_next_reference([In] ConnectionHandle ldapHandle, [In] IntPtr result); 303 304 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_get_dnW", CharSet = CharSet.Unicode)] ldap_get_dn([In] ConnectionHandle ldapHandle, [In] IntPtr result)305 public static extern IntPtr ldap_get_dn([In] ConnectionHandle ldapHandle, [In] IntPtr result); 306 307 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_first_attributeW", CharSet = CharSet.Unicode)] ldap_first_attribute([In] ConnectionHandle ldapHandle, [In] IntPtr result, ref IntPtr address)308 public static extern IntPtr ldap_first_attribute([In] ConnectionHandle ldapHandle, [In] IntPtr result, ref IntPtr address); 309 310 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_next_attributeW", CharSet = CharSet.Unicode)] ldap_next_attribute([In] ConnectionHandle ldapHandle, [In] IntPtr result, [In, Out] IntPtr address)311 public static extern IntPtr ldap_next_attribute([In] ConnectionHandle ldapHandle, [In] IntPtr result, [In, Out] IntPtr address); 312 313 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_free", CharSet = CharSet.Unicode)] ber_free([In] IntPtr berelement, int option)314 public static extern IntPtr ber_free([In] IntPtr berelement, int option); 315 316 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_get_values_lenW", CharSet = CharSet.Unicode)] ldap_get_values_len([In] ConnectionHandle ldapHandle, [In] IntPtr result, string name)317 public static extern IntPtr ldap_get_values_len([In] ConnectionHandle ldapHandle, [In] IntPtr result, string name); 318 319 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_value_free_len", CharSet = CharSet.Unicode)] ldap_value_free_len([In] IntPtr berelement)320 public static extern IntPtr ldap_value_free_len([In] IntPtr berelement); 321 322 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_parse_referenceW", CharSet = CharSet.Unicode)] ldap_parse_reference([In] ConnectionHandle ldapHandle, [In] IntPtr result, ref IntPtr referrals)323 public static extern int ldap_parse_reference([In] ConnectionHandle ldapHandle, [In] IntPtr result, ref IntPtr referrals); 324 325 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_alloc_t", CharSet = CharSet.Unicode)] ber_alloc(int option)326 public static extern IntPtr ber_alloc(int option); 327 328 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_printf", CharSet = CharSet.Unicode)] ber_printf_emptyarg(BerSafeHandle berElement, string format)329 public static extern int ber_printf_emptyarg(BerSafeHandle berElement, string format); 330 331 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_printf", CharSet = CharSet.Unicode)] ber_printf_int(BerSafeHandle berElement, string format, int value)332 public static extern int ber_printf_int(BerSafeHandle berElement, string format, int value); 333 334 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_printf", CharSet = CharSet.Unicode)] ber_printf_bytearray(BerSafeHandle berElement, string format, HGlobalMemHandle value, int length)335 public static extern int ber_printf_bytearray(BerSafeHandle berElement, string format, HGlobalMemHandle value, int length); 336 337 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_printf", CharSet = CharSet.Unicode)] ber_printf_berarray(BerSafeHandle berElement, string format, IntPtr value)338 public static extern int ber_printf_berarray(BerSafeHandle berElement, string format, IntPtr value); 339 340 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_flatten", CharSet = CharSet.Unicode)] ber_flatten(BerSafeHandle berElement, ref IntPtr value)341 public static extern int ber_flatten(BerSafeHandle berElement, ref IntPtr value); 342 343 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_init", CharSet = CharSet.Unicode)] ber_init(berval value)344 public static extern IntPtr ber_init(berval value); 345 346 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_scanf", CharSet = CharSet.Unicode)] ber_scanf(BerSafeHandle berElement, string format)347 public static extern int ber_scanf(BerSafeHandle berElement, string format); 348 349 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_scanf", CharSet = CharSet.Unicode)] ber_scanf_int(BerSafeHandle berElement, string format, ref int value)350 public static extern int ber_scanf_int(BerSafeHandle berElement, string format, ref int value); 351 352 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_scanf", CharSet = CharSet.Unicode)] ber_scanf_ptr(BerSafeHandle berElement, string format, ref IntPtr value)353 public static extern int ber_scanf_ptr(BerSafeHandle berElement, string format, ref IntPtr value); 354 355 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_scanf", CharSet = CharSet.Unicode)] ber_scanf_bitstring(BerSafeHandle berElement, string format, ref IntPtr value, ref int length)356 public static extern int ber_scanf_bitstring(BerSafeHandle berElement, string format, ref IntPtr value, ref int length); 357 358 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_bvfree", CharSet = CharSet.Unicode)] ber_bvfree(IntPtr value)359 public static extern int ber_bvfree(IntPtr value); 360 361 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ber_bvecfree", CharSet = CharSet.Unicode)] ber_bvecfree(IntPtr value)362 public static extern int ber_bvecfree(IntPtr value); 363 364 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_create_sort_controlW", CharSet = CharSet.Unicode)] ldap_create_sort_control(ConnectionHandle handle, IntPtr keys, byte critical, ref IntPtr control)365 public static extern int ldap_create_sort_control(ConnectionHandle handle, IntPtr keys, byte critical, ref IntPtr control); 366 367 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_control_freeW", CharSet = CharSet.Unicode)] ldap_control_free(IntPtr control)368 public static extern int ldap_control_free(IntPtr control); 369 370 [DllImport("Crypt32.dll", EntryPoint = "CertFreeCRLContext", CharSet = CharSet.Unicode)] CertFreeCRLContext(IntPtr certContext)371 public static extern int CertFreeCRLContext(IntPtr certContext); 372 373 [DllImport(Wldap32dll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ldap_result2error", CharSet = CharSet.Unicode)] ldap_result2error([In] ConnectionHandle ldapHandle, [In] IntPtr result, int freeIt)374 public static extern int ldap_result2error([In] ConnectionHandle ldapHandle, [In] IntPtr result, int freeIt); 375 } 376 } 377