Use DsBindWithCred . Please note that this feature does not work with Access Denied, even if the credentials are technically sound, such as account lockout. You will need to use the LogonUser function if you need this level of detail, but each call will be considered a login attempt.
using System.Runtime.InteropServices; using System.ComponentModel; using System.Text; public class PInvoke { public static bool TestCreds(string usernamePossiblyWithDomain, SecureString password, string dnsDomainName) { string username, usernameDomain; ParseUserName(usernamePossiblyWithDomain, out username, out usernameDomain); IntPtr pPass = Marshal.SecureStringToGlobalAllocUnicode(password); try { IntPtr hDS = IntPtr.Zero; IntPtr authID = MakePassCreds(username, usernameDomain, pPass);
source share