カテゴリー: JAVA

LDAP ActiveDirectory 参考資料

参考資料
 
アクセスする場合のDN or user は、CN=Administrator,CN=Users,DC=testdom,DC=com でも administrator@testdom.com でもよい
どっちの形式でもよい
Base DN=”CN=Users,DC=testdom,DC=com” で見たとき
各ユーザの見え方はこうなる DN=”CN=鈴木 花子,CN=Users,DC=testdom,DC=com”
その時 DN=”CN=鈴木 花子,CN=Users,DC=testdom,DC=com” 各ユーザはこれがユーザIDになる
LDAPLIST
 
登録ユーザ一覧を見る場合は、ビルトインアカウントはいらないので、フィルターは以下のようになる。
(&(&(&(objectCategory=person)(objectClass=user))(objectClass=organizationalPerson))(!(isCriticalSystemObject=TRUE)))
LDAPLIST

 

ActiveDirectoryの入ったサーバとLDAPでSSL通信を行うためには、ドメインの証明書とサーバ証明書を入れたキーストア(keystore)を作成する

ActiveDirectoryの入ったサーバとLDAPでSSL通信を行うためには、ドメインの証明書とサーバ証明書を入れたキーストア(keystore)を作成する必要があります。
1.ActiveDirectoryのドメインの証明書とサーバ証明書の取得方法
(1)ドメインコントローラに証明書サービスをインストールする。
サーバの役割の追加で ActiveDirectory 証明書サービスを選択して追加する。
image001
image002
image003
image004
image005
image006
image007
image008
image009
インストールを行う。インストールが完了したら再起動する。

再起動しないとドメインコントローラーの証明書が表示されない。

(2)インストールした認証局の証明書とドメインコントローラサーバーの証明書を取得する。
インストールした認証局の証明書の名前は適当に cacert.cer とする。
image010
ドメインコントローラサーバーの証明書の名前は適当に dcsrv.cer とする。
image011
(3)Javaのキーツール( keytool.exe )を使って、キーストアーを作成する
keytool.exe -import -trustcacerts -alias caroot -file “caroot.cer” -keystore “cacerts”
keytool.exe -import -trustcacerts -alias dcsrv -file “dcsrv.cer” -keystore “cacerts”
この場合のキーストアーのファイルの名前は cacerts というファイル名になる。
キーストアーは信頼した認証局やサーバーの証明書が入るため、alias (別名) がぶつからないようにしなくてはいけないので -alias で指定する。
以上で終わり・・・
 
 
 

 

eclipse3.6 デバッグ時のTOMCAT6 でのログ出力の設定 

eclipse3.6(PLEIADES)では、c:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 がcatalina.homeになっている。
workspace を c:\workspace としているが、自分の環境に合わせて設定してください。

1.アクセスログを出す場合
 
 c:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xmlの修正
 アクセスログ出力の項目がコメントアウトされているので、コメントアウトを解除する。

[text]
<–
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”
prefix=”localhost_access_log.” suffix=”.txt” pattern=”common” resolveHosts=”false”/>
–>
[/text]
                  ↓
[text]
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”
prefix=”localhost_access_log.” suffix=”.txt” pattern=”common” resolveHosts=”false”/>
[/text]

2.いわゆるログをログファイルに記録する場合

 2.1.サーバー起動時の設定を修正する。
    起動構成を開く->引数に以下を追加する。

[text]
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=”c:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\logging.properties”
[/text]

 2.2.logging.properties ファイルをコピーする
    c:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf に logging.properties ファイルをコピーする。
    logging.properties は、TOMCAT_HOME\confにあるのを使用してください。

JAVA でファイル名を分解するクラス

JAVA でファイル名を分解するクラス
[text]
package jp.computer-system.util.file;

public class FileString
{
private String filePath = “”;
private String drive;
private String folder;
private String fileName;
private String ext;

public FileString()
{
}

public FileString(String filePath)
{
this.filePath = filePath;
String[] strs = filePath.split(“[/,\\\\]”);
if(strs.length == 0 ) return;
int six = 0;
if(!(strs[0].indexOf(“:”)==-1))
{
six=1;
drive = strs[0];
}
folder = “”;
for(int i=six;i<(strs.length – 1);i++)
{
if(folder.length()!=0)
{
folder += "/" + strs[i];
}
else
{
folder = strs[i];
}
}
fileName = strs[strs.length -1];
int ip = fileName.lastIndexOf(".");
if(ip==-1)
{
ext = "";
}
else
{
if((ip+1)==fileName.length())
{
ext = "";
}
else
{
ext = fileName.substring(ip + 1);
}
}
}

public String getDrive() {
return drive;
}
public void setDrive(String drive) {
this.drive = drive;
}
public String getFolder() {
return folder;
}
public void setFolder(String folder) {
this.folder = folder;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getExt() {
return ext;
}
public void setExt(String ext) {
this.ext = ext;
}

public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
}

[/text]

OpenLdapにLINUXユーザーアカウントを作ったけどその他の情報もLDAPに入れておきたかったので作ったSchema

/etc/openldap/schema フォルダーに ldapusers.schema を作成した。

[text]
attributetype ( 1.1.2.1.1.500.1
NAME ‘userName’
DESC ‘jp.compsys user name UTF8’
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch <—- filter の部分文字列検索するためには必要か?!
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{200} )

attributetype ( 1.1.2.1.1.500.2
NAME 'mailAddress'
DESC 'jp.compsys email address'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )

attributetype ( 1.1.2.1.1.500.3
NAME 'mailAddressMobile'
DESC 'jp.compsys mobile email address'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )

objectclass ( 1.1.2.1.1.100.1
NAME 'personalInfo'
DESC 'jp.compsys personal information'
SUP top AUXILIARY
MAY ( userName $ mailAddress $ mailAddressMobile ) )

[/text]

/etc/openldap/slapd.conf にldapusers.schema を追加する。修正したら slapd を再起動する。
[text]
include /etc/openldap/schema/nis.schema
include /etc/openldap/schema/openldap.schema
include /etc/openldap/schema/ppolicy.schema
include /etc/openldap/schema/collective.schema
include /etc/openldap/schema/ldapusers.schema <—–ここ
[/text]

javaで使うときは
[text]
// objectClass(必須)
Attribute attrObjClass = new BasicAttribute(“objectClass”);
attrObjClass.add(0, “top”);
attrObjClass.add(1, “account”);
attrObjClass.add(2, “posixAccount”);
attrObjClass.add(3, “personalInfo”);
attrs.put(attrObjClass);
[/text]