powershell - Exception in "ValidateCredentials" "The server cannot handle directory requests." -
i use windows powershell query , validate user's windows credentials during installation process. worked until yesterday. department in company has changed configuration of domain controller , following exception.
exception calling "validatecredentials" "2" argument(s): "the server cannot handle directory requests." @ line:32 char:5 + if ($pc.validatecredentials($username, $credential.getnetworkcredenti ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : notspecified: (:) [], methodinvocationexception + fullyqualifiederrorid : directoryoperationexception
from research found out has missing ssl connection. have add contextoptions.securesocketlayer
somewhere in code. the question is: right place put parameter? cannot find examples powershell.
here's script used check credentials:
$credential = $host.ui.promptforcredential("need credentials.", "for using windows integrated authentication please provide login information user has access microsoft sql server database.", "", "") if (!$credential) { write-output "no credentials provided" return } [system.reflection.assembly]::loadwithpartialname('system.directoryservices.accountmanagement') $system = get-wmiobject -class win32_computersystem if ($credential.getnetworkcredential().domain) { write-output "credentials contain domain" if ($credential.getnetworkcredential().domain -eq $system.name) { write-output "domain local system" $pc = new-object -typename system.directoryservices.accountmanagement.principalcontext 'machine', $system.name } else { write-output "domain network domain" $pc = new-object -typename system.directoryservices.accountmanagement.principalcontext 'domain', $credential.getnetworkcredential().domain } $username = $credential.username } elseif (0, 2 -contains $system.domainrole) { $pc = new-object -typename system.directoryservices.accountmanagement.principalcontext 'machine', $system.name $username = $system.name + '\' + $credential.getnetworkcredential().username } else { $pc = new-object -typename system.directoryservices.accountmanagement.principalcontext 'domain', $system.domain $username = $system.domain + '\' + $credential.getnetworkcredential().username } if ($pc.validatecredentials($username, $credential.getnetworkcredential().password)) { write-output "validation successfull" } else { write-output "validation failed" }
as mentioned kiran in comments, can pass contextoptions
value principalcontext
constructor:
$defaultnc = "dc=$($system.domain -replace '\.',',dc=')" # ... $pc = new-object -typename system.directoryservices.accountmanagement.principalcontext 'domain', $system.domain, $defaultnc, ([system.directoryservices.accountmanagement.contextoptions]'securesocketlayer,negotiate')
an authentication option (negotiate
or simplebind
) must specified, 'securesocketlayer,negotiate'
value
Comments
Post a Comment