2011-08-25 8 views
1

와 (49) 잘못된 자격 증명이는 내가 사용하고있는 수입 있습니다LDAP 예외 : 잘못된 자격 증명 Grails의

import com.novell.ldap.*; 
import java.io.UnsupportedEncodingException; 

를 나는 내가 찾은 아주 간단한 암호 검증을하려고 오전 :

http://developer.novell.com/documentation/samplecode/jldap_sample/index.htm

저는 바인딩이 작동하지 않는 것처럼 보입니다. 누구든지 grails 나 java로 이것을하는 더 좋은 방법이 있나. 나는 정말로 잃어버린 자신을 찾으며 어떤 모범이나 지침이 도움이 될 것이다.

감사합니다.

+0

사람들은 플러그인되지 않습니다, 그들은 수입이야. 플러그인을 사용하고 있습니까? –

+0

당신의 권리, 나의 나쁜. 나는 gldapo 플러그인을 사용하고 있었고이 수입으로 전환했습니다. 섞어서 미안 해요 – xander528

답변

1

이 Java 예제는 UnboundID LDAP SDK을 사용하여 디렉토리 서버에 연결하고 바인드합니다. 이 같은 실행

$ java -cp YOUR_CLASSPATH BindExample hostname port bindDn password 

BindExample.java :

import com.unboundid.ldap.sdk.BindRequest; 
import com.unboundid.ldap.sdk.BindResult; 
import com.unboundid.ldap.sdk.Control; 
import com.unboundid.ldap.sdk.LDAPConnection; 
import com.unboundid.ldap.sdk.LDAPException; 
import com.unboundid.ldap.sdk.ResultCode; 
import com.unboundid.ldap.sdk.SimpleBindRequest; 

public final class BindExample { 

    public static void main(String... args) { 
    if(args.length == 4) { 
     final String hostname = args[0]; 
     final String dn = args[2]; 
     final String password = args[3]; 
     int port; 
     LDAPConnection ldapConnection; 
     try { 
      port = Integer.parseInt(args[1]); 
     } catch(NumberFormatException nfx) { 
      System.err.println(args[1] + " is not an integer, using 389"); 
      port = 389; 
     } 
     try { 
      ldapConnection = 
       new LDAPConnection(hostname,port); 
     } catch(final LDAPException lex) { 
      System.err.println("failed to connect to " 
        + hostname + " " + 
        lex.getMessage()); 
      return; 
     } 
     try { 
      final BindRequest bindRequest = 
       new SimpleBindRequest(dn,password); 
      BindResult bindResult = 
       ldapConnection.bind(bindRequest); 
      if(bindResult.getResultCode() == ResultCode.SUCCESS) { 
       System.out.println("authentication successful"); 
      } 
      if(bindResult.hasResponseControl()) { 
       Control[] controls = 
        bindResult.getResponseControls(); 
       // handle response controls ... 
      } 
      ldapConnection.close(); 
     } catch(final LDAPException lex) { 
      System.err.println("bind failed"); 
      ldapConnection.close(); 
      return; 
     } 
    } 
    } 
} 
+0

귀하의 게시물을 가져 주셔서 감사합니다. 나는 오늘 아침 동료와 함께 나의 문제를 해결했다. 호스트 파일을 넣을 때 전체 URL을 넣었습니다. URL을 입력해야합니다. – xander528