LDAP スクリプトの例
次のスクリプトの例では、LDAP サーバーに Active Directory (AD) を使用していることを前提としています。
userAccountControl 属性値スクリプト
この例では、無効なユーザー (514 または 546) に関連付けられた userAccountControl 属性値をソースでテストします。//Deactivate LDAP-disabled users during transform based on 'userAccountControl' attribute
if(source.u_useraccountcontrol == '514' || source.u_useraccountcontrol == '546'){
target.active=false;
target.locked_out=true;
}ビットごとのチェックを使用した例を次に示します。
if(source.u_useraccountcontrol & 2){
active = false;
}
userAccountControl 属性スクリプト
この例では、userAccountControl 属性を調べますが、特定の値をテストしません。LDAP ユーザーアカウントを再有効化するオプションも含まれています。/*
* Deactivate LDAP-disabled users during transform based on 'userAccountControl' attribute
* Convert the userAccountControl attribute back to a hex value
*/
var ctrl = parseInt(source.u_useraccountcontrol, 10);
ctrl = ctrl.toString(16);
/*
* The only digit we care about is the final one
* A final hex digit value of '2' in 'ctrl' means disabled
*/
if(ctrl.substr(-1) == "2"){
//Deactivate and lock the user account
target.active = false;
target.locked_out = true;
//Ignore any insert of a disabled record
if(action == 'insert'){
ignore = true;
}
}
/* Optional: Uncomment else block to reactivate and unlock the user account
else {
target.active = true;
target.locked_out = ctrl.substr(-2, 1) == "1";
}
*/onBefore 変換マップスクリプト
onBefore 変換マップスクリプトの例を次に示します。スクリプトは、無効なレコードと挿入されるレコードを識別します。無効なユーザーの挿入が発生している場合、操作の変換はレコードを無視します。//Ignore any insert of a disabled record as defined by the 'userAccountControl' attribute
var uc = source.u_useraccountcontrol;
if((uc == '514' || uc == '546') && action == 'insert'){
ignore = true;
}DN メンバースクリプト
このスクリプトの例では、546 および 514 userAccountControl 値に依存せずに、ユーザーが特定の識別名 (DN) のメンバーであるかどうかをチェックすることで、柔軟性を導入しています。このスクリプトは、「テーブル変換マップ」レコードの [スクリプト] フィールドまたは onBefore 変換マップスクリプトで使用できます。//Deactivate LDAP-disabled users during transform based on OU membership in 'dn'
if(source.u_dn.indexOf('OU=Disabled Accounts') > -1){
target.active = false;
target.locked_out = true;
}