---
sourceDocument: Yokohama 플랫폼 보안
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/yokohama/platform-security

 Release :

    - yokohama

ft:locale :

    - ko-KR

ft:publication_title :

    - Yokohama 플랫폼 보안

ft:clusterId :

    - psec

bundleId :

    - psec

workflow :

    - Platform


---

# LDAP 스크립트 예시

# LDAP 스크립트 예시 {#ariaid-title1}

* 릴리스 버전: Yokohama
* 
* 업데이트 날짜 2025년 01월 30일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 3분

다음 스크립트 예시에서는 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;
    }


