龍彭艇?委厮厚仟議方象亟秘万參念侭壓議凋兆貧和猟嶄。勣 恂欺宸匯泣?夸俶勣岑祇厮厚仟訳朕議凋兆貧和猟。繍朴沫貧和猟?喘栖朴沫斤?議貧和猟?嚥斤?議 RDN 潤栽?祥辛參侘撹 Java 斤?議凋兆貧和猟。壓 賠汽 10 議化帶 17 嶄辛參心欺宸泣。
繍侭嗤奉來亟秘厮厚仟議 Java 斤??壓繍厚仟議 Java 斤?亟指 ApacheDS 扮?頁壓揖匯凋兆貧和 猟貧亟秘仟議方象訳朕。侭嗤嚥方象訳朕嗤購議奉來脅繍卿払。侭參?俶勣繍方象訳朕議侭嗤奉來亟指厮 厚仟議 Java 斤?。壓賠汽 10 議化帶 18 嶄?厘議侃尖頁貫朴沫潤惚響函侭嗤奉來?旺繍万断淫廾壓奉 來鹿栽嶄。
恷朔?壓化帶 19 嶄距喘 DirContext.rebind() 圭隈。rebind() 圭隈俊辺議歌方祥頁壓 StoreBobPreferences 哘喘殻會議 賠汽 4 議化帶 4 嶄勧弓公揮嗤眉倖歌方議 bind() 圭隈議歌方。
bind() 才 rebind() 圭隈岻寂立匯議曝艶頁 rebind() 圭隈繍方象訳朕贋刈壓?嗤方象訳朕厮将媼象 議凋兆貧和猟嶄?貫遇嗤丼仇喘仟方象厚仟?嗤訳朕。
哘喘殻會 9. 忝栽壓匯軟
悳潤宸鐙猟嫗扮?厘繍喘恷朔匯倖哘喘殻會委肉書葎峭僥欺議侭嗤古廷脅怏栽欺匯倖酒汽議、辛嶷喘 議斤?嶄?宸倖斤?辛參壓 ApacheDS 嶄贋刈、朴沫、評茅才厚仟 Java 斤?。LDAP4JavaObjects 窃泌 賠汽 11 侭幣?
賠汽 11. LDAP4JavaObjects
public class LDAP4JavaObjects {
protected String commonName = null;
protected String surName = null;
protected String userID = null;
protected String javaObjectCN = null;
protected String userName = null;
protected String password = null;
protected String initialContext = null;
private String workingContext = null;
protected DirContext dirContext = null;
protected Properties properties = null;
protected Object javaObject = null;
protected Attributes attributes = null;
public LDAP4JavaObjects() {
properties = new Properties();
attributes = new BasicAttributes(true);
workingContext = "ou=users";
initialContext = workingContext;
try {
InputStream inputStream = new FileInputStream ( "ApacheDS.properties");
properties.load(inputStream);
} catch (Exception e) {
e.printStackTrace();
}
}//LDAPJavaObjects
public void setUserName(String userName){
properties.setProperty("java.naming.security.principal", userName);
this.userName = userName;
}
public void setPassword(String password) {
properties.setProperty("java.naming.security.credentials", password);
this.password = password;
}
protected void connect() {
try {
// Fetch the directory context.
dirContext= new InitialDirContext(properties);
} catch (NamingException e) {
System.out.println("Getting initial context operation failed: " + e);
}
}
protected void close() {
try {
// Close the directory context.
dirContext.close();
} catch (NamingException e) {
|