암호 재설정 연장 스크립트
확장 스크립트를 사용하면 자격 증명 스토어, 검증 또는 식별 유형의 기능을 확장할 암호 재설정 수 있습니다.
암호 재설정 확장 스크립트 포함
각 스크립트 포함은 양식의 해당 필드에서 암호 재설정 사용할 수 있는 특정 범주와 연결됩니다.
"등록 확인" 스크립트 포함 범주
| 스크립트 포함 범주 | 설명 | 메서드 서명 | 입력 필드 | 출력 필드 |
|---|---|---|---|---|
| 등록 확인 | 사용자가 지정된 검증에 등록되었는지 확인합니다. | 프로세스(매개변수) | 매개 변수:
|
반환값: (부울) true, 사용자가 지정된 검증에 등록된 경우; 그렇지 않으면 false입니다. |
이 등록 확인 예에서는 예상 매개변수가 모두 제공되면 사용자가 등록되었음을 알립니다. 코드는 SampleEnrollmentCheck라는 확장 스크립트의 스크립트 필드에 포함됩니다.
var SampleEnrollmentCheck = Class.create ();
SampleEnrollmentCheck. prototype = {
category:'password_reset.extension.enrollment_check', // DO NOT REMOVE THIS LINE!
/**********
* Returns boolean telling whether the user is enrolled.
* This sample returns true if both parameters are supplied, false otherwise
*
* @param params.userId The sys-id of the user being checked (table: sys_user)
* @param params.verificationId The sys-id of the verification being checked (table: pwd_verification)
* @return Boolean indicating whether the user is enrolled into the specified verification
**********/
process:function (params) {return (params.userId && params.verificationId)? true:false; },
type:'SampleEnrollmentCheck'};
"등록 양식 프로세서" 스크립트 포함 범주
| 스크립트 포함 범주 | 설명 | 메서드 서명 | 입력 필드 | 출력 필드 |
|---|---|---|---|---|
| 등록 양식 프로세서 | 필요한 모든 정보가 사용자로부터 수집되었는지 확인합니다. 사용자가 암호를 재설정할 때 검증에 사용할 수 있도록 정보를 저장합니다. | 프로세스(매개변수) | 매개 변수:
등록 프로세스의 상태에 다음 정보를 추가해야 합니다.
|
반환값: (부울) true, 사용자가 지정된 검증에 등록된 경우; 그렇지 않으면 false입니다. |
이 예시에서는 사용자가 제출한 응답이 성공한 경우 등록 양식 제출을 성공적으로 처리합니다. 코드는 SampleEnrollmentProcessor라는 확장 스크립트의 스크립트 필드에 포함됩니다.
var SampleEnrollmentProcessor = Class.create ();
SampleEnrollmentProcessor.prototype = {
category: 'password_reset.extension.enrollment_form_processor', // DO NOT REMOVE THIS LINE!
/**********
* Process the enrollment form request, and return whether the user was successfully enrolled.
*
* @param params.userId The sys_id of the user trying to enroll (table: sys_user)
* @param params.verificationId The sys_id of the verification to be enrolled into (table: pwd_verification)
* @param params.enrollmentId The sys_id of this enrollment process
* @param request The form request object. Felds in the form can be accessed with
* request.getParameter('<element-id>')
* @return boolean telling whether the user was successfully enrolled
* The following information should be added to the state of the enrollment process
* gs.getSession().putProperty("result.status",status) - whether the user was successfully enrolled
* gs.getSession().putProperty("result.message",message) - an associated message to be returned
* to the UI. Eg. a detailed error message
* gs.getSession().putProperty("result.value",value) - custom value associated with the enrollment
**********/
processForm:function (params, request) {var verificationId = params.verificationId; var sampleInput = request.getParameter ('sample_input');
if (gs.nil (verificationId) || (sampleInput!= 'success')) { return false; }
var now_GR = new GlideRecord ('sys_user');
now_GR.get (params. userId);
now_GR.print ('User:' + now_GR.getValue ('user_name') + ' successfully enrolled'); return true; },
type: 'SampleEnrollmentProcessor' };
"식별 양식 프로세서" 스크립트 포함 범주
| 스크립트 포함 범주 | 설명 | 메서드 서명 | 입력 필드 | 출력 필드 |
|---|---|---|---|---|
| 식별 양식 프로세서 | 식별 양식 요청을 처리합니다. | processForm(매개변수, 요청) | 매개 변수:
|
반환: 요청된 입력에 해당하는 사용자의 sys_id. 사용자를 찾을 수 없는 경우 null을 반환합니다. |
이 예에서는 식별 양식에서 제출된 사용자 이름이 지정된 sys_user 테이블 내에서 사용자를 식별하려고 시도합니다. 코드는 PwdIdentifyViaUsername이라는 확장 스크립트의 스크립트 필드에 포함됩니다.
var PwdIdentifyViaUsername = Class.create ();
PwdIdentifyViaUsername. prototype = {
category: 'password_reset.extension.identification_form_processor', // DO NOT REMOVE THIS LINE!
initialize: function () { },
/**********
* Process the identification form request, and returns the user's sys_id. If user was not identified return null.
*
* @param params.processId The sys_id of the calling 암호 재설정 process (table: pwd_process)
* @param request The form request object. fields in the form can be accessed with
* request.getParameter('<element-id>')
* Supported request parameters: sysparm_user_id - the user identifier value entered in the form
* @return The sys_id of the user that corresponds to the requested input;
* if no user was found, null should be returned
**********/
processForm: function (params, request) {var processId = params. processId; var sysparm_user_id = request.getParameter ('sysparm_user_id');
now_GR = new GlideRecord ('sys_user') ;
now_GR.addQuery ('user_name', sysparm_user_id) ;
now_GR.query (); if (!now_GR.next ()) {return null; } return now_GR.sys_id;},
type:'PwdIdentifyViaUsername' }
"암호 작성기" 스크립트 포함 범주
| 스크립트 포함 범주 | 설명 | 메서드 서명 | 입력 필드 | 출력 필드 |
|---|---|---|---|---|
| 암호 작성기 | 자동 생성된 암호를 반환합니다. | 프로세스(매개변수) | Parameters:params.processId - 호출 암호 재설정 프로세스(테이블: pwd_process)의 sys_id입니다. | 반환값: (문자열) 자동 생성된 암호입니다. |
이 예제에서는 기본 단어와 숫자에서 임의로 암호를 생성합니다. 자격 증명 스토어에 따라 기본 단어가 선택됩니다. 코드는 SamplePasswordGenerator라는 확장 스크립트의 스크립트 필드에 포함됩니다.
var SamplePasswordGenerator = Class.create ();
SamplePasswordGenerator. prototype = {
category: 'password_reset.extension.password_generator', // DO NOT REMOVE THIS LINE!
/**********
* Returns an auto-generated string password.
* This sample randomly generates 4 digits to add to the password.
*
* @param params.credentialStoreId The sys_id of the target 암호 재설정 credential store to generate
* a password for (table: pwd_cred_store)
* @return An auto-generated string password
**********/
process:function (params) { var basePassword ;
var now_GR = new GlideRecord ('pwd_cred_store');
now_GR.addQuery ('name', 'Local ServiceNow Instance');
now_GR.query (); if (now_GR.next ()) { if (params.credentialStoreId = now_GR.getValue ('sys_id'))
basePassword = "Password"; else
basePassword = "Dorwssap"; } return this. generateSimple (basePassword); },
generateSimple:function (base) {var pwd = base; var numbers = '0123456789'; var length = 4;
for (var i = 0 , n = numbers. length ; i < length ; i ++) {
pwd += numbers.charAt (Math.floor (Math.random () * n) + 1); } return pwd;},
type:'SamplePasswordGenerator'} ;
"재설정 후" 스크립트 포함 범주
| 스크립트 포함 범주 | 설명 | 메서드 서명 | 입력 필드 | 출력 필드 |
|---|---|---|---|---|
| 재설정 후 | 프로세스가 완료된 암호 재설정 후 추가 작업을 수행합니다. | 프로세스(매개변수) | 매개 변수:
|
반환: void |
이 예에서는 실패한 재설정 요청을 시스템 로그에 추가합니다. 코드는 PwdPostProcessor'라는 확장 스크립트의 스크립트 필드에 포함됩니다.
var PwdPostProcessor = Class.create ();
PwdPostProcessor. prototype = {
category: 'password_reset.extension.post_reset_script', // DO NOT REMOVE THIS LINE!
initialize:function () { },
/**********
* Execute custom actions after the 암호 재설정 process has completed.
*
* @param params.resetRequestId The sys_id of the current 암호 재설정 request (table: pwd_reset_request)
* @param params.wfSuccess A flag indicating if the workflow completed sucessfully.
* True if (and only if) successful.
* @return no return value
**********/
process: function (params) {if (!params. wfSuccess) {
now_GS.log ('[PwdPostProcessor.process] failure post processing for request [' + params. resetRequestId + ']'); }
// We could place actions here that we always want executed return; },
type:'PwdPostProcessor' }
'사용자 계정 조회' 스크립트 포함 범주
| 스크립트 포함 범주 | 설명 | 메서드 서명 | 입력 필드 | 출력 필드 |
|---|---|---|---|---|
| 사용자 계정 조회 | 지정된 사용자의 자격 증명 스토어 계정 ID를 가져옵니다. | 프로세스(매개변수) | Parameters:params.userId - 검사할 사용자의 sys_id입니다(테이블: sys_user). | 반환: (문자열) 지정된 사용자의 자격 증명 스토어 계정 ID입니다. |
이 예제에서는 사용자에 대한 자격 증명 스토어 계정을 가져옵니다. 이 코드는 SampleUserAccountLookupExtension이라는 확장 스크립트의 스크립트 필드에 포함됩니다.
var SampleUserAccountLookupExtension = Class.create ();
SampleUserAccountLookupExtension. prototype = {
category:'password_reset.extension.user_account_lookup', // DO NOT REMOVE THIS LINE!
/**********
* Returns the credential store account id for a given user.
* This sample echoes the user_id supplied as the credential store account id for that user.
*
* @param params.userId The sys_id of the user being checked (table: sys_user)
* @return The credential store account id (string) for a given user
**********/
process:function (params) {return params.userId;},
type:'SampleUserAccountLookupExtension' }
"검증 양식 프로세서" 스크립트 포함 범주
| 스크립트 포함 범주 | 설명 | 메서드 서명 | 입력 필드 | 출력 필드 |
|---|---|---|---|---|
| 검증 양식 프로세서 | 검증 양식 요청을 처리하고 사용자가 검증되었는지 여부를 나타냅니다. | processForm(매개변수, 요청) | 매개 변수:
|
반환 값 : (부울) true, 사용자가 확인 된 경우; 그렇지 않으면 false입니다. |
이 예제에서는 사용자가 입력 필드에서 ok 를 보낸 경우에만 true를 반환하는 확인 프로세서를 보여 줍니다. 그렇지 않으면 false를 반환합니다. 코드는 SampleVerificationFormProcessor라는 확장 스크립트의 스크립트 필드에 포함됩니다.
var SampleVerificationFormProcessor = Class.create ();
SampleVerificationFormProcessor.prototype = {
category:'password_reset.extension.verification_form_processor', // DO NOT REMOVE THIS LINE!
/**********
* Process the verification form request, and return whether the user was successfully verified.
* This is a sample verification processor returns true only if the user sent "ok" in the input field;
* otherwise, it returns false.
*
* @param params.resetRequestId The sys_id of the current 암호 재설정 request (table: pwd_reset_request)
* @param params.userId The sys_id of the user trying to be verified (table: sys_user)
* @param params.verificationId The sys_id of the verification to be processed (table: pwd_verification)
* @param request The form request object. Fields in the form can be accessed with
* request.getParameter('<element-id>')
* @return Boolean indicating whether the user is successfully verified
**********/
processForm:function (params, request) {if (request.getParameter ("sysparm_simple_input") == "ok") return true; else return false; },
type:'SampleVerificationFormProcessor'};