database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
ㆍLDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
LDAP Q&A 1596 게시물 읽기
No. 1596
[질문] openLDAP에서 JNDI이용시 에러
작성자
한아람(higon)
작성일
2002-07-31 12:05
조회수
4,622

openLDAP에 JNDI를 이용해 책에 있는 소스를 구현해 봤습니다.

Search만 하면 되는데 자꾸 에러나 나네요 고수님들 부탁 드립니다.

 

내용은 아래와 같습니다.

[root@mail servlet]# java JNDISearch ou=Manager,o=mail.cubetech.co.kr

 

애트리뷰트가 실패하였습니다.

 

javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; rema

ining name 'ou=Manager,o=mail.cubetech.co.kr'

 

자바소스

//package webmail;
import java.util.Hashtable;
import java.util.Enumeration;

import javax.naming.*;
import javax.naming.directory.*;

class JNDISearch {
	public static void main(String[] args) {
		String returnedAttributes[]=;
		
		Hashtable env = new Hashtable();
		env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
		env.put(Context.PROVIDER_URL, "ldap://211.222.124.20:389");
		env.put(Context.SECURITY_AUTHENTICATION,"simple");
		env.put(Context.SECURITY_PRINCIPAL,"cn=Manager,dc=mail,dc=cubetech,dc=co,dc=kr");
		env.put(Context.SECURITY_CREDENTIALS,"testpass");
		
		
		SearchControls constraints = new SearchControls();
		
		constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
		constraints.setReturningAttributes(returnedAttributes);
		
		try {
			DirContext context = new InitialDirContext(env);
			
			NamingEnumeration searchResults = context.search( args[0], "(uid=admin)", constraints);
			
			while(searchResults.hasMore()) {
				SearchResult nextResult = (SearchResult) searchResults.next();
				System.out.println("이름: " +nextResult.getName());
				
				Attributes attributeSet = nextResult.getAttributes();
				System.out.println("이 애트리뷰트의 크기: "+attributeSet.size());
				
				if (attributeSet.size() == 0) {
					System.out.println("애트리뷰트 값이 없습니다.");
				} else {
					NamingEnumeration allAttributes = attributeSet.getAll();
					
					while(allAttributes.hasMoreElements()) {
						Attribute attribute = (Attribute)allAttributes.next();
						String attributeID = attribute.getID();
						
						if(attribute.size() > 1) {
							Enumeration allValues = attribute.getAll();
							
							while(allValues.hasMoreElements()) {
								System.out.println(attributeID+":"+allValues.nextElement());
							}
						} else if (attribute.size() > 0) 
						System.out.println(attributeID+":"+attribute.get());
						else
						System.out.println("애트리뷰트 값이 없습니다.");
					}
				}
				System.out.println();
			}
		}
		catch(NamingException e)
		{
			System.err.println("애트리뷰트가 실패하였습니다.");
			e.printStackTrace();
		}
		catch(Error e)
		{
			System.err.println("이 애트리뷰트는 JDK1.1을 지원하지 않습니다.");
			e.printStackTrace();
		}
		finally
		{
			System.exit(0);
		}
	}
}
							
slapd.conf파일내용
# $OpenLDAP: pkg/ldap/servers/slapd/slapd.conf,v 1.8.8.7 2001/09/27 20:00:31 kur
t Exp $
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include         /usr/local/etc/openldap/schema/core.schema

# Define global ACLs to disable default read access.

# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral       ldap://root.openldap.org

pidfile         /usr/local/var/slapd.pid
argsfile        /usr/local/var/slapd.args

# Load dynamic backend modules:
# modulepath    /usr/local/libexec/openldap
# moduleload    back_ldap.la
# moduleload    back_ldbm.la
# moduleload    back_passwd.la
# moduleload    back_shell.la
#
# Sample Access Control
#       Allow read access of root DSE
#       Allow self write access
#       Allow authenticated users read access
#       Allow anonymous users to authenticate
#
#access to dn="" by * read
#access to *
#       by self write
#       by users read
#       by anonymous auth
#
# if no access controls are present, the default is:
#       Allow read by all
#
# rootdn can always write!

#######################################################################
# ldbm database definitions
#######################################################################

database        ldbm
suffix          "dc=mail,dc=cubetech,dc=co,dc=kr"
#suffix         "o=My Organization Name,c=US"
rootdn          "cn=Manager,dc=mail,dc=cubetech,dc=co,dc=kr"
#rootdn         "cn=Manager,o=My Organization Name,c=US"
# Cleartext passwords, especially for the rootdn, should
# be avoid.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw  testpass
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd/tools. Mode 700 recommended.
#directory      /usr/local/var/openldap-ldbm
directory       /usr/local/db2
# Indices to maintain
index   objectClass     eq

최상위 엔트리 입력
[root@mail libexec]# ldapadd -x -D "cn=Manager,dc=mail,dc=cubetech,dc=co,dc=kr"
 -W -h mail.cubetech.co.kr << EOF
> dn: dc=mail,dc=cubetech,dc=co,dc=kr
> dc: mail
> objectclass: dcobject
> EOF
Enter LDAP Password:
adding new entry "dc=mail,dc=cubetech,dc=co,dc=kr"
==> 입력은 성공했어요

 

그런데 자바로 파일을 찾아도 그렇고 .....명령을 쳐도 그렇게 왜안나오는지..

 

고수님들 제발 답변좀 .....부탁드립니다.

[Top]
No.
제목
작성자
작성일
조회
1602VPN장비에서의 외부 LDAP Server
연승흠
2002-08-04
4534
1603┕>Re: VPN장비에서의 외부 LDAP Server
서호정
2002-08-05 10:46:17
4454
1601Openldap 설치시 configure option
이병주
2002-08-04
4295
1598[질문] objectclass를 새로 하나 만들고 싶습니다.
진재용
2002-08-01
4433
1599┕>Re: [질문] objectclass를 새로 하나 만들고 싶습니다. [1]
서호정
2002-08-01 20:26:38
4521
1596[질문] openLDAP에서 JNDI이용시 에러
한아람
2002-07-31
4622
1595OpenLDAP에서 데이타 백업시 에러
이건수
2002-07-31
4723
1594LDAP과 Single Sign On
이동주
2002-07-30
4745
1600┕>Re: LDAP과 Single Sign On [1]
서호정
2002-08-01 20:40:30
5274
1593허접임다. ou=people아래 사용자를 add하고 싶습니다.
김창영
2002-07-30
4424
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.028초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다