LDAP 문서 원본 보기
←
LDAP
둘러보기로 가기
검색하러 가기
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요:
요청한 명령은 다음 권한을 가진 사용자에게 제한됩니다:
사용자
.
이 문서는 편집하거나 다른 명령을 할 수 없도록 보호되어 있습니다.
문서의 원본을 보거나 복사할 수 있습니다.
DBMS와 마찬가지로 웹에서 사용자 인증을 위해 많이 사용되는 LDAP을 정리 한다. ==LDAP URLs== *http://docs.sun.com/source/816-6678-10/url.htm *ldap[s]://<hostname>:<port>/<base_dn>?<attributes>?<scope>?<filter> :*scope : base, one, sub :*Escaping Unsafe Characters ::space (%20), < (%3c), > (%3e), " (%22), # (%23) ::$ (%25), { (%7b), } (%7d), | (%7c), \ (%5c) ::^ (%5e), ~ (%7e), [ (%5b), ] (%5d), ` (%60) :*Sample ldap://localhost:389/ou=people,o=jopenbusiness.com??sub?objectclass=* ldap://localhost:389/ou=People,o=jopenbusiness.com??sub?uid=admin - Active Directory ldap://localhost:389/CN=산사랑,CN=Users,DC=jopenbusiness,DC=com??sub?uid=* ==LDAP Java API 샘플== //--- scope : base, one, sub ldap://<hostname>:<port>/<base_dn>?<attribute, attribute, . . .>?<scope>?<filter> import java.util.*; import netscape.ldap.*; public class theLdap { public static void main(String[] args) { LDAPConnection ld = null; try { ld = new LDAPConnection(); ld.connect("localhost", 389); ld.authenticate(3, "admin", "admin"); //--- Simple Authentication //--- Search LDAPSearchConstraints cons = ld.getSearchConstraints(); cons.setOption(LDAPv2.SIZELIMIT, 1000); cons.setOption(LDAPv2.TIMELIMIT, 0); cons.setOption(LDAPv2.BATCHSIZE, 0); //--- scope : LDAPv2.SCOPE_SUB, SCOPE_ONE, SCOPE_BASE //--- filter : =, >=, <=, ~= (sound), = * (all) //--- &. and, |. or, !. not //--- attrs : null, LDAPv3.NO_ATTRS, LDAPv3.ALL_USER_ATTRS LDAPSearchResults res = ld.search(String base, int scope, String filter, Stirng attrs[], boolean attrsOnly = false, LDAPSearchConstraints cons); String[] sortAttrs = ("~", "~"); boolean[] ascending = {true, true}; res.sort(new LDAPCompareAttrNames(sortAttrs, ascending)); //--- Getting Entries while (res.hasMoreElements()) { LDAPEntry entry = null; try { entry = res.next(); } catch(LDAPRefferralException e) { LDAPUrl refUrls[] = e.getURLs(); String url = refUrls[i].getURL(); continue; } catch (LDAPExecption e) { continue; } String entryDN = entry.getDN(); //--- Getting Distinguished Names //--- Getting Atributes LDAPAttributeSet attrSet = entry.getAttributeSet(); Enumeration enumAttrs = attrSet.getAttributes(); while (enumAttrs.hasMoreElements()) { LDAPAttribute attr = (LDAPAttribute)enumAttrs.nextElement(); //--- Get name and values String attrName = attr.getName(); Enumeration enumVals = attr.getStringValues(); if (enumVals != null) { while (enumVals.hasMoreElements()) { String value = (String)enumVals.nextElement(); } } } } //--- Read String entryDN = "uid=honggildong, ou=People, o=daou.co.kr"; LDAPEntry entry = ld.read(entryDN); //--- Getting Atributes LDAPAttributeSet attrSet = entry.getAttributeSet(); Enumeration enumAttrs = attrSet.getAttributes(); while (enumAttrs.hasMoreElements()) { LDAPAttribute attr = (LDAPAttribute)enumAttrs.nextElement(); //--- Get name and values String attrName = attr.getName(); Enumeration enumVals = attr.getStringValues(); if (enumVals != null) { while (enumVals.hasMoreElements()) { String value = (String)enumVals.nextElement(); } } } //--- Add //--- Create attribute Sting objectclasses[] = {"top", "person"}; LDAPAttribute attr_1 = new LDAPAttribute("~", "~"); LDAPAttribute attr_2 = new LDAPAttribute("objectclass", objectclases); //--- Create attribute set LDAPAttributeSet attrSet = new LDAPAttributeSet(); attrSet.add(attr_1); attrSet.add(attr_2); //--- Creating entry String entryDN = "uid=honggildong, ou=People, o=daou.co.kr"; LDAPEntry entry = new LDAPEntry(entryDN, attrSet); //--- Adding entry ld.add(entry); //--- Modify LDAPModificationSet mods = new LDAPModificationSet(); LDAPAttribute attr = new LDAPAttribute("~", "~"); LDAPAttribute attr = new LDAPAttribute("~"); //--- LDAPModification : ADD, DELETE, REPLACE mods.add(LDAPModification.ADD, attr); String entryDN = "uid=honggildong, ou=People, o=daou.co.kr"; ld.modify(entryDN, mods); //--- Delete String entryDN = "uid=honggildong, ou=People, o=daou.co.kr"; ld.delete(entryDN); //--- Rename String entryDN = "uid=honggildong, ou=People, o=daou.co.kr"; ld.rename(entryDN, "uid=hello", deleteOldRDN = true); //--- Compare String entryDN = "uid=honggildong, ou=People, o=daou.co.kr"; LDAPAttribute attr = new LDAPAttribute("~", "~"); boolean ok = ld.compare(entryDN, attr); } catch(LDAPException e) { int resultCode = e.getLDAPResultCode(); String errorMsg = e.getLDAPErrorMessage(); String errorMsg1 = e.errorCodeToString(resultCode); System.exit(1); } finally { try { if ((ld != null) && (ld.isCinnected())) ld.disconnect(); } catch (LDAPExecption e) {} } System.exit(0); } } ==참고 문헌== *[[OpenLDAP]] [[Category:기술_자료실]] [[Category:LDAP]]
LDAP
문서로 돌아갑니다.
둘러보기 메뉴
개인 도구
로그인
이름공간
문서
토론
변수
보기
읽기
원본 보기
역사 보기
더 보기
검색
주요 메뉴
오픈소스 컨설팅
오픈소스
오픈소스 라이선스
오픈소스 커뮤니티
오픈소스 종류
오픈소스 현황
오픈소스 한글화
문자셋과 인코딩
Storage
Network
보안
고가용성
모니터링
오픈 API
오픈 서비스
Cloud
BigData
Android
산사랑 노트
둘러보기
인기 문서
최근 수정 문서
모든 문서
모든 분류
임의 문서
위키 사용법
자매 사이트
CMS
오비컨 홈페이지
오비컨 CMS
블로그
데모 - SuiteCRM
산사랑의 Twitter
산사랑의 Facebook
친구 사이트
공개SW 포털
OLIS
한국공개소프트웨어협회
AppCenter 지원본부
OLC
PSEG
개발자 블로그
블로터
개인 메뉴
메뉴 수정
양식함
도구
여기를 가리키는 문서
가리키는 글의 최근 바뀜
특수 문서 목록
문서 정보