LDAP ldap_exop_passwd
(PHP 7 >= 7.2.0, PHP 8)
ldap_exop_passwd — PASSWD 확장 작업 도우미
설명
ldap_exop_passwd( LDAP\Connection $ldap, string $user = "", string $old_password = "", string $new_password = "", array &$controls = null ): string|bool
PASSWD 확장 작업을 수행합니다.
매개변수
ldap
- ldap_connect()에 의해 반환된 LDAP\Connection 인스턴스입니다.
user
- 비밀번호를 변경할 사용자의 dn.
old_password
- 이 사용자의 이전 비밀번호입니다. 서버 구성에 따라 생략될 수 있습니다.
new_password
- 이 사용자의 새 암호입니다. 생성된 암호를 갖기 위해 생략하거나 비어 있을 수 있습니다.
controls
- 제공된 경우 비밀번호 정책 요청 제어가 요청과 함께 전송되고 이는 요청과 함께 반환된 LDAP 제어 배열로 채워집니다.
반환 값
new_password
가 비어 있거나 생략된 경우 생성된 암호를 반환합니다. 그렇지 않으면 성공하면 true
를, 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.1.0 | ldap 매개변수는 이제 LDAP\Connection 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다. |
8.0.0 | controls 은 이제 nullable입니다. 이전에는 []로 기본 설정되었습니다. |
7.3.0 | controls 지원 추가됨 |
Examples
예제 #1 PASSWD 확장 작업
<?php
$ds = ldap_connect("localhost"); // assuming the LDAP server is on this host
if ($ds) {
// bind with appropriate dn to give update access
$bind = ldap_bind($ds, "cn=root, o=My Company, c=US", "secret");
if (!$bind) {
echo "Unable to bind to LDAP server";
exit;
}
// use PASSWD EXOP to change the user password for a generated one
$genpw = ldap_exop_passwd($ds, "cn=root, o=My Company, c=US", "secret");
if ($genpw) {
// use the generated password to bind
$bind = ldap_bind($ds, "cn=root, o=My Company, c=US", $genpw);
}
// set the password back to "secret"
ldap_exop_passwd($ds, "cn=root, o=My Company, c=US", $genpw, "secret");
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?>
기타
- ldap_exop() - 확장 작업을 수행합니다.
- ldap_parse_exop() - LDAP 확장 작업에서 결과 개체 구문 분석