LDAP ldap_add
(PHP 4, PHP 5, PHP 7, PHP 8)
ldap_add — LDAP 디렉토리에 항목 추가
설명
ldap_add( LDAP\Connection $ldap, string $dn, array $entry, ?array $controls = null ): bool
LDAP 디렉토리에 항목을 추가하십시오.
매개변수
ldap
- ldap_connect()에 의해 반환된 LDAP\Connection 인스턴스입니다.
dn
- LDAP 엔티티의 고유 이름입니다.
entry
- 항목에 대한 정보를 지정하는 배열입니다. 항목의 값은 개별 속성에 의해 인덱싱됩니다. 속성에 대한 값이 여러 개인 경우 0부터 시작하는 정수를 사용하여 인덱싱됩니다.
<?php $entry["attribute1"] = "value"; $entry["attribute2"][0] = "value1"; $entry["attribute2"][1] = "value2"; ?>
controls
- 요청과 함께 보낼 LDAP 컨트롤의 배열입니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.1.0 | ldap 매개변수는 이제 LDAP\Connection 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다. |
8.0.0 | controls 은 이제 nullable입니다. 이전에는 []로 기본 설정되었습니다. |
7.3.0 | controls 지원 추가됨 |
Examples
예제 #1 인증된 바인드가 있는 완전한 예
<?php
$ds = ldap_connect("localhost"); // assuming the LDAP server is on this host
if ($ds) {
// bind with appropriate dn to give update access
$r = ldap_bind($ds, "cn=root, o=My Company, c=US", "secret");
// prepare data
$info["cn"] = "John Jones";
$info["sn"] = "Jones";
$info["objectclass"] = "person";
// add data to directory
$r = ldap_add($ds, "cn=John Jones, o=My Company, c=US", $info);
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?>
메모
참고: 이 함수는 바이너리 안전합니다.
기타
- ldap_add_ext() - LDAP 디렉토리에 항목 추가
- ldap_delete() - 디렉토리에서 항목 삭제