One way to use LDAP for system verification

zhaozj2021-02-16  74

/ * * Create Date 2004-7-3 * * Change the generated file template to * Window> Preferences> Java> Code Generation> Code and Comments * / package com.eastfreeman.auth;

Import Netscape.ldap. *;

/ ** * @Author Eastfreeman * * Change the template for the generated type annotation to * Window> Preferences> Java> Code Generation> Code and Note * / Public Class Authforad {

public static boolean login (String hostname, int port, String username, String password) throws Exception {boolean flag = false; // boolean flag = false; LDAPConnection ld = null; ld = new LDAPConnection (); String HOSTNAME = hostname; int Port = port; string entrydntest = "cn =" username ", cn = useers, dc = domain, dc = local"; try {ld.connect (Hostname, Port, EntryDntest, PaG = true;} catch LDAPEXCEPTION E) {FLAG = false;} / * done, so disconnect * / if (ld! = Null) && ld.isconnected ()) {Try {ld.disconnect ();} catch (ldapexception e) {system. Out.println ("Error:" E.TOString ());}} Return flag;

}

转载请注明原文地址:https://www.9cbs.com/read-17612.html

New Post(0)