LDAP
LDAP (경량 디렉터리 접근 프로토콜)
LDAP는 '디렉터리 서버'에 접근하기 위한 프로토콜이에요. 디렉터리는 정보를 트리 구조로 보관하는 특별한 종류의 데이터베이스라고 생각하면 돼요. 회사 구성원, 조직, 장비 같은 계층적 정보를 조회할 때 씁니다.
본문
소개
LDAP는 Lightweight Directory Access Protocol의 약자로, '디렉터리 서버'에 접근하는 데 쓰는 프로토콜이에요. 디렉터리는 정보를 트리 구조로 담는 특별한 종류의 데이터베이스예요.
개념은 여러분이 쓰는 하드 디스크 디렉터리 구조와 비슷해요. 다만 여기서는 루트 디렉터리가 '세계(The world)'이고, 첫 번째 레벨 하위 디렉터리는 '국가(countries)'예요. 더 아래 레벨에는 회사, 조직, 장소에 대한 항목이 들어 있고, 더 내려가면 사람, 장비, 문서 같은 디렉터리 항목을 만날 수 있어요.
하드 디스크의 하위 디렉터리에 있는 파일을 가리킬 때 이런 식으로 쓰죠.
/usr/local/myapp/docs
슬래시(/)가 참조의 각 구분을 표시하고, 순서는 왼쪽에서 오른쪽으로 읽어요.
LDAP에서 이 '완전한 파일 참조'에 해당하는 게 distinguished name, 줄여서 dn이에요. dn의 예시는 이렇습니다.
cn=John Smith,ou=Accounts,o=My Company,c=US
쉼표(,)가 참조의 각 구분을 표시하고, 순서는 오른쪽에서 왼쪽으로 읽어요. 이 dn은 이렇게 해석돼요.
country = US
organization = My Company
organizationalUnit = Accounts
commonName = John Smith
하드 디스크의 디렉터리 구조를 어떻게 정리할지에 대한 절대 규칙이 없는 것처럼, 디렉터리 서버 관리자도 목적에 맞게 구조를 정할 수 있어요. 다만 몇 가지 관례는 있어요. 핵심은, 디렉터리 서버에 접근하는 코드를 짜려면 데이터베이스를 쓰려면 그 안에 뭐가 있는지 알아야 하는 것처럼, 그 서버의 구조를 어느 정도 알아야 한다는 거예요.
LDAP에 대한 많은 정보는 Mozilla, OpenLDAP Project, 그리고 Internet Engineering Taskforce의 RFC 4510~4519 에서 찾을 수 있어요. Netscape SDK에는 도움이 되는 HTML 형식의 Programmer's Guide도 있어요.
함수 참조
LDAP Functions
ldap_8859_to_t61— Translate 8859 characters to t61 charactersldap_add— Add entries to LDAP directoryldap_add_ext— Add entries to LDAP directoryldap_bind— Bind to LDAP directoryldap_bind_ext— Bind to LDAP directoryldap_close— Alias of ldap_unbindldap_compare— Compare value of attribute found in entry specified with DNldap_connect— Connect to an LDAP serverldap_connect_wallet— Connect to an LDAP serverldap_control_paged_result— Send LDAP pagination controlldap_control_paged_result_response— Retrieve the LDAP pagination cookieldap_count_entries— Count the number of entries in a searchldap_count_references— Counts the number of references in a search resultldap_delete— Delete an entry from a directoryldap_delete_ext— Delete an entry from a directoryldap_dn2ufn— Convert DN to User Friendly Naming formatldap_err2str— Convert LDAP error number into string error messageldap_errno— Return the LDAP error number of the last LDAP commandldap_error— Return the LDAP error message of the last LDAP commandldap_escape— Escape a string for use in an LDAP filter or DNldap_exop— Performs an extended operationldap_exop_passwd— PASSWD extended operation helperldap_exop_refresh— Refresh extended operation helperldap_exop_sync— Performs an extended operationldap_exop_whoami— WHOAMI extended operation helperldap_explode_dn— Splits DN into its component partsldap_first_attribute— Return first attributeldap_first_entry— Return first result idldap_first_reference— Return first referenceldap_free_result— Free result memoryldap_get_attributes— Get attributes from a search result entryldap_get_dn— Get the DN of a result entryldap_get_entries— Get all result entriesldap_get_option— Get the current value for given optionldap_get_values— Get all values from a result entryldap_get_values_len— Get all binary values from a result entryldap_list— Single-level searchldap_mod_add— Add attribute values to current attributesldap_mod_add_ext— Add attribute values to current attributesldap_mod_del— Delete attribute values from current attributesldap_mod_del_ext— Delete attribute values from current attributesldap_mod_replace— Replace attribute values with new onesldap_mod_replace_ext— Replace attribute values with new onesldap_modify— Alias of ldap_mod_replaceldap_modify_batch— Batch and execute modifications on an LDAP entryldap_next_attribute— Get the next attribute in resultldap_next_entry— Get next result entryldap_next_reference— Get next referenceldap_parse_exop— Parse result object from an LDAP extended operationldap_parse_reference— Extract information from reference entryldap_parse_result— Extract information from resultldap_read— Read an entryldap_rename— Modify the name of an entryldap_rename_ext— Modify the name of an entryldap_sasl_bind— Bind to LDAP directory using SASLldap_search— Search LDAP treeldap_set_option— Set the value of the given optionldap_set_rebind_proc— Set a callback function to do re-binds on referral chasingldap_sort— Sort LDAP result entries on the client sideldap_start_tls— Start TLSldap_t61_to_8859— Translate t61 characters to 8859 charactersldap_unbind— Unbind from LDAP directory
클래스 참조
LDAP\Connection— The LDAP\Connection classLDAP\Result— The LDAP\Result classLDAP\ResultEntry— The LDAP\ResultEntry class
더 알아보기
- LDAP에 접근하려면 서버 구조(DN 구성)를 알아야 해요. 처음에는
ldap_connect()→ldap_bind()→ldap_search()→ldap_get_entries()흐름을 익혀 보세요. - 보안 연결이 필요하면
ldap_start_tls()를 쓰면 TLS를 시작할 수 있어요.