4
I have the code in PHP LDAP to change password in Active Directory:
<?php
$usuario="xxx";
$senha_atual="0000";
$senha_nova="11111";
$pessoas="casa.cafe.br";
$servidor="1.1.1.1";
$porta=389;
$portas=636;
$base="CN=$usuario,CN=Users,DC=casa,DC=cafe,DC=br";
$rdn=$usuario."@".$pessoas;
$con = @ldap_connect("ldap://".$servidor, $portas) or die("Erro na conexao ao servidor {$servidor}");
if ($con) {
ldap_set_option($con, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($con, LDAP_OPT_REFERRALS, 0);
$bind = ldap_bind($con, $rdn, $senha_atual);
echo "Passou do ldap_bind($con, $usuario."@".$pessoas, $senha_atual);";
// verify binding
if ($bind) {
$userdata["mail"] = "[email protected]";
$userdata["unicodepwd"] = iconv( 'UTF-8', 'UTF-16LE', "\"".$senha_nova."\"" );
echo "<pre>";
var_dump($userdata);
echo "</pre>";
$rs = ldap_modify($con, $base, $userdata);
echo "<br><br>";
ldap_get_option($con,LDAP_OPT_ERROR_STRING,$error);
echo $error;
echo "<br><br>";
if ($rs) {
$msg="Senha foi atualizada com sucesso!";
}else{
$msg="Ocorreu um erro ao trocar a senha! Contate o Administrador.";
}
} else {
$msg="Usuario inexistente ou senha incorreta! Tente novamente.";
}
}
?>
When I try to change the user password shows the following message:
Warning: ldap_modify(): Modify: Server is unwilling to perform in
Using the code:
ldap_get_option($con,LDAP_OPT_ERROR_STRING,$error);
echo $error;
Show this message:
0000001F: Svcerr: DSID-031A129B, problem 5003 (WILL_NOT_PERFORM), date 0
Searching I found solutions that say that to be able to change the password I need a PHP SSL connection with Windows AD, how can I configure the PHP of my local machine that is running XAMPP and Windows AD to be able to connect via SSL?
bs.: Using XAMPP with PHP Version 7.1.1 (Local Host) and Windows Server 2012 (Network Server).
Put the windows tag to call the guys that start better AD. I was curious with this question
– Daniel
I just posted @Daniel, thanks.
– TGO