LDAP
piSmartLdapServiceSample
import com.PowerIntegral.*;
/**
* <p>
* Title: piSmartLdapServiceSample
* </p>
*
* <p>
* Description: 調用 LDAP 服務類別範例
* </p>
*/
public class piSmartLdapServiceSample extends piSmartServiceSample {
/**
* piSmartLdapServiceSample: 建構子
*
* @param ConfigurationFile
* String => 定義檔
*/
public piSmartLdapServiceSample(String ConfigurationFile) {
super(ConfigurationFile);
}
/**
* main: 主函式
*
* @param args =>
* 命令列字串引數陣列
*/
public static void main(String[] args) {
String _ConfigurationFile = "piSmartService.properties";
if (args.length > 0) {
_ConfigurationFile = args[0];
}
java.io.File _FileProp = new java.io.File(_ConfigurationFile);
if (!_FileProp.exists()) {
System.out.println("定義檔:" + _ConfigurationFile + " 不存在");
return;
}
piSmartLdapServiceSample _piSmartLdapServiceSample = new piSmartLdapServiceSample(
_ConfigurationFile);
_piSmartLdapServiceSample.Init("piSmartServiceSample",
"piSmartLdapServiceSample", "PowerIntegral", "Mitac");
// ***************************************************************
String _ldapEntry = _piSmartLdapServiceSample._Configuration
.getProperty("AttributePathForDisplay"), _Result = "";
_Result = _piSmartLdapServiceSample._piSmartService.getLDAPEntryValue(
_ldapEntry, "cn");
if (!_piSmartLdapServiceSample._piSmartService.getSuccess())
_piSmartLdapServiceSample._piSmartService.getLog()
.Debug(
500,
_piSmartLdapServiceSample._piSmartService
.getErrorMessage());
// ***************************************************************
_piSmartLdapServiceSample._piSmartService.getJNDI()
.DisplayAttributeValues(_ldapEntry, System.out);
// ***************************************************************
String _ldapSearchBase = _piSmartLdapServiceSample._Configuration
.getProperty("ldapSearchBase");
String _ldapSearchFilter = _piSmartLdapServiceSample._Configuration
.getProperty("ldapSearchFilter");
_Result = _piSmartLdapServiceSample._piSmartService.searchLDAPEntries(
_ldapSearchBase, _ldapSearchFilter);
if (!_piSmartLdapServiceSample._piSmartService.getSuccess())
_piSmartLdapServiceSample._piSmartService.getLog()
.Debug(
510,
_piSmartLdapServiceSample._piSmartService
.getErrorMessage());
// ***************************************************************
String _newPassword = piDateTime.DateTimeString().replaceAll("[.\\s:]",
"");
if (!_piSmartLdapServiceSample._piSmartService.changeLDAPPassword(
_ldapEntry, _newPassword)) {
_piSmartLdapServiceSample._piSmartService.getLog()
.Debug(
520,
_piSmartLdapServiceSample._piSmartService
.getErrorMessage());
}
// ***************************************************************
}
}