Exemplo n.º 1
0
        internal static NtStatus SamConnectWithCreds(string serverName, out SafeSamHandle serverHandle, SamServerAccessMask accessMask, SafeRpcAuthIdentityHandle authIdentity)
        {
            uint          unknown              = 0;
            IntPtr        objectAttributes     = IntPtr.Zero;
            UnicodeString unicodeServerName    = new UnicodeString(serverName);
            string        servicePrincipalName = spnPrefix + serverName;
            NtStatus      result = SamConnectWithCreds(ref unicodeServerName, out serverHandle, accessMask, objectAttributes, authIdentity, servicePrincipalName, out unknown);

            if (result == NtStatus.RpcUnknownAuthenticationService)
            {
                // Try it again, but without the SPN
                servicePrincipalName = null;
                return(SamConnectWithCreds(ref unicodeServerName, out serverHandle, accessMask, objectAttributes, authIdentity, servicePrincipalName, out unknown));
            }
            else
            {
                return(result);
            }
        }
Exemplo n.º 2
0
 private static extern NtStatus SamConnectWithCreds([In] ref UnicodeString serverName, out SafeSamHandle serverHandle, SamServerAccessMask accessMask, IntPtr objectAttributes, SafeRpcAuthIdentityHandle authIdentity, [MarshalAs(UnmanagedType.LPWStr)] string servicePrincipalName, out uint unknown);
Exemplo n.º 3
0
 internal static Win32ErrorCode DsMakePasswordCredentials(string user, string domain, SecureString password, out SafeRpcAuthIdentityHandle authIdentity)
 {
     using (var passwordPointer = new SafeUnicodeSecureStringPointer(password))
     {
         return(DsMakePasswordCredentials(user, domain, passwordPointer, out authIdentity));
     }
 }
Exemplo n.º 4
0
 internal static Win32ErrorCode DsMakePasswordCredentials(NetworkCredential credential, out SafeRpcAuthIdentityHandle authIdentity)
 {
     return(DsMakePasswordCredentials(credential.UserName, credential.Domain, credential.SecurePassword, out authIdentity));
 }
Exemplo n.º 5
0
 private static extern Win32ErrorCode DsMakePasswordCredentials(string user, string domain, SafeUnicodeSecureStringPointer password, out SafeRpcAuthIdentityHandle authIdentity);