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;
}