LDAP

LDAP (경량 디렉터리 접근 프로토콜)

LDAP는 '디렉터리 서버'에 접근하기 위한 프로토콜이에요. 디렉터리는 정보를 트리 구조로 보관하는 특별한 종류의 데이터베이스라고 생각하면 돼요. 회사 구성원, 조직, 장비 같은 계층적 정보를 조회할 때 씁니다.

출처: Lightweight Directory Access Protocol

본문

소개

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 characters
  • ldap_add — Add entries to LDAP directory
  • ldap_add_ext — Add entries to LDAP directory
  • ldap_bind — Bind to LDAP directory
  • ldap_bind_ext — Bind to LDAP directory
  • ldap_close — Alias of ldap_unbind
  • ldap_compare — Compare value of attribute found in entry specified with DN
  • ldap_connect — Connect to an LDAP server
  • ldap_connect_wallet — Connect to an LDAP server
  • ldap_control_paged_result — Send LDAP pagination control
  • ldap_control_paged_result_response — Retrieve the LDAP pagination cookie
  • ldap_count_entries — Count the number of entries in a search
  • ldap_count_references — Counts the number of references in a search result
  • ldap_delete — Delete an entry from a directory
  • ldap_delete_ext — Delete an entry from a directory
  • ldap_dn2ufn — Convert DN to User Friendly Naming format
  • ldap_err2str — Convert LDAP error number into string error message
  • ldap_errno — Return the LDAP error number of the last LDAP command
  • ldap_error — Return the LDAP error message of the last LDAP command
  • ldap_escape — Escape a string for use in an LDAP filter or DN
  • ldap_exop — Performs an extended operation
  • ldap_exop_passwd — PASSWD extended operation helper
  • ldap_exop_refresh — Refresh extended operation helper
  • ldap_exop_sync — Performs an extended operation
  • ldap_exop_whoami — WHOAMI extended operation helper
  • ldap_explode_dn — Splits DN into its component parts
  • ldap_first_attribute — Return first attribute
  • ldap_first_entry — Return first result id
  • ldap_first_reference — Return first reference
  • ldap_free_result — Free result memory
  • ldap_get_attributes — Get attributes from a search result entry
  • ldap_get_dn — Get the DN of a result entry
  • ldap_get_entries — Get all result entries
  • ldap_get_option — Get the current value for given option
  • ldap_get_values — Get all values from a result entry
  • ldap_get_values_len — Get all binary values from a result entry
  • ldap_list — Single-level search
  • ldap_mod_add — Add attribute values to current attributes
  • ldap_mod_add_ext — Add attribute values to current attributes
  • ldap_mod_del — Delete attribute values from current attributes
  • ldap_mod_del_ext — Delete attribute values from current attributes
  • ldap_mod_replace — Replace attribute values with new ones
  • ldap_mod_replace_ext — Replace attribute values with new ones
  • ldap_modify — Alias of ldap_mod_replace
  • ldap_modify_batch — Batch and execute modifications on an LDAP entry
  • ldap_next_attribute — Get the next attribute in result
  • ldap_next_entry — Get next result entry
  • ldap_next_reference — Get next reference
  • ldap_parse_exop — Parse result object from an LDAP extended operation
  • ldap_parse_reference — Extract information from reference entry
  • ldap_parse_result — Extract information from result
  • ldap_read — Read an entry
  • ldap_rename — Modify the name of an entry
  • ldap_rename_ext — Modify the name of an entry
  • ldap_sasl_bind — Bind to LDAP directory using SASL
  • ldap_search — Search LDAP tree
  • ldap_set_option — Set the value of the given option
  • ldap_set_rebind_proc — Set a callback function to do re-binds on referral chasing
  • ldap_sort — Sort LDAP result entries on the client side
  • ldap_start_tls — Start TLS
  • ldap_t61_to_8859 — Translate t61 characters to 8859 characters
  • ldap_unbind — Unbind from LDAP directory

클래스 참조

  • LDAP\Connection — The LDAP\Connection class
  • LDAP\Result — The LDAP\Result class
  • LDAP\ResultEntry — The LDAP\ResultEntry class

더 알아보기

  • LDAP에 접근하려면 서버 구조(DN 구성)를 알아야 해요. 처음에는 ldap_connect()ldap_bind()ldap_search()ldap_get_entries() 흐름을 익혀 보세요.
  • 보안 연결이 필요하면 ldap_start_tls()를 쓰면 TLS를 시작할 수 있어요.