Esempio n. 1
0
 public static extern int DsBindWithCred(
     string DomainControllerName,
     string DnsDomainName,
     SafeDsCredentialsHandle AuthIdentity,
     out SafeDsHandle phDS
 );
Esempio n. 2
0
 public static extern int DsMakePasswordCredentials(
     string User,
     string Domain,
     string Password,
     out SafeDsCredentialsHandle pAuthIdentity
 );
Esempio n. 3
0
 private SafeDsHandle Bind(SafeDsCredentialsHandle credential)
 {
     return Bind(_serverName, _domainName, credential);
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        private static SafeDsHandle Bind(string server, string domain, SafeDsCredentialsHandle credentials)
        {
            SafeDsHandle handle;
            int retval = TryBind(server, domain, credentials, out handle);

            if (retval == NativeMethods.ERROR_INVALID_PARAMETER)
            {
                // HACK: you must specify port number for AD LDS instances, but you MUST NOT
                // specify it when connecting to AD DS domain

                int colon = server.LastIndexOf(':');
                if (colon > -1)
                {
                    server = server.Substring(0, colon);
                }

                retval = TryBind(server, domain, credentials, out handle);
            }

            NativeMethods.EnforceSuccess(retval);

            return handle;
        }
Esempio n. 6
0
 public static extern int DsMakePasswordCredentials(
     string User,
     string Domain,
     string Password,
     out SafeDsCredentialsHandle pAuthIdentity
     );
Esempio n. 7
0
 public static extern int DsBindWithCred(
     string DomainControllerName,
     string DnsDomainName,
     SafeDsCredentialsHandle AuthIdentity,
     out SafeDsHandle phDS
     );