Test Passwords Against Active Directory User

Tool to test password against Active Directory user. Multiple passwords can be tested by ; separating them

Usage: CheckCredentials.exe FQDN USERNAME PASSWORD1[;PASSWORD2;PASSWORD3..]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.DirectoryServices.AccountManagement;
using System.Diagnostics;

namespace CheckCredentials
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.GetUpperBound(0) == 2)
            {
                foreach (string password in args[2].Split(';'))
                {
                    using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, args[0]))
                    {

                        // validate the credentials
                        bool isValid = pc.ValidateCredentials(args[1], password);

                        if (isValid)
                        {
                            Console.WriteLine(@"{1}@{0} has password {2}", args[0], args[1], password);
                        }

                    }
                }
            }
            else
            {
                Console.WriteLine("Usage:{0} FQDN USERNAME PASSWORD1[;PASSWORD2;PASSWORD3..]", Process.GetCurrentProcess().ProcessName + ".exe");
            }
        }
    }
}

Attachment(s):

View Shaun Vermaak's profile on LinkedIn

Leave a Reply