0

hello in my domain we have an app where domain admin logon with user/password . for validate credential are valide i use this code.

 public bool IsValidDomainCredential(string user , string password)
        {
            if (password == null || user == null) { return false; }

            bool valid = false;
            using (PrincipalContext context = new PrincipalContext(ContextType.Domain,"DWfoo.foo"))
            {

                valid = context.ValidateCredentials(user, password);
            }
            return valid;
        }

it worked well but this year our admin have mixed autentification smartcart and password.

and something in smartcard driver seem interact with this code cuz when it execute it crash the application with exeption.

System.DirectoryServices.Protocols.DirectoryOperationException 

The server can not handle directory requests

sometime it will not crash and ask for code PIN of the smartcard then if i don't cancel it crash again if i cancel i can logon.

i'm afraid this will happen at any application call on active directory and i have 0 idea how to totaly ignor smartcard driver and interaction.

Zwan
  • 632
  • 2
  • 6
  • 23
  • Which line throws the exception? Are the `user` and `password` variables set to valid values when it happens? – Gabriel Luci Oct 22 '18 at 13:13
  • valid = context.ValidateCredentials(user, password); this line yes they valid – Zwan Oct 22 '18 at 13:40
  • 1
    There are a couple different answers here that might help: https://stackoverflow.com/questions/3694919/nets-directory-services-throws-a-strange-exception – Gabriel Luci Oct 22 '18 at 13:45
  • thanks for the link this fixed the behavior. bool valid = context.ValidateCredentials(user, pass, ContextOptions.Negotiate); not sure what it does but no more smartcard popup or error – Zwan Oct 22 '18 at 13:59

0 Answers0