public static extern int DsCrackNames( SafeDsHandle hDS, DsNameFlags flags, DsNameFormat formatOffered, DsNameFormat formatDesired, int cNames, string[] rpNames, out IntPtr ppResult //pointer to pointer of DS_NAME_RESULT );
public static extern int DsBindWithCred( string DomainControllerName, string DnsDomainName, SafeDsCredentialsHandle AuthIdentity, out SafeDsHandle phDS );
public static extern int DsBind( string DomainControllerName, string DnsDomainName, out SafeDsHandle phDS );
private static DsNameResultItem[] CrackNames( SafeDsHandle hDS, DsNameFlags flags, DsNameFormat formatOffered, DsNameFormat formatDesired, string[] names) { PscxArgumentException.ThrowIfIsNullOrEmpty(names); IntPtr ptr = IntPtr.Zero; try { NativeMethods.EnforceSuccess(NativeMethods.DsCrackNames( hDS, flags, formatOffered, formatDesired, names.Length, names, out ptr)); DsNameResult result = Utils.PtrToStructure<DsNameResult>(ptr); IEnumerable<DsNameResultItem> items = Utils.ReadNativeArray<DsNameResultItem>(result.rItems, result.cItems); return new List<DsNameResultItem>(items).ToArray(); } finally { NativeMethods.DsFreeNameResult(ptr); } }
private static int TryBind(string server, string domain, SafeDsCredentialsHandle credentials, out SafeDsHandle handle) { if (credentials != null) { return NativeMethods.DsBindWithCred(server, domain, credentials, out handle); } return NativeMethods.DsBind(server, domain, out handle); }