user-provisioning
Complete user lifecycle management including creation, role assignment, group membership, and deprovisioning
Happy Technologies LLC · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add Happy-Technologies-LLC/happy-platform-skills --skill user-provisioning技能说明
name: user-provisioning version: 1.0.1 description: Complete user lifecycle management including creation, role assignment, group membership, and deprovisioning author: Happy Technologies LLC tags: [admin, user-management, provisioning, roles, groups, security, onboarding, offboarding] platforms: [claude-code, claude-desktop, chatgpt, cursor, any] tools: mcp: - SN-List-SysUsers - SN-List-SysUserGroups - SN-Create-Record - SN-Update-Record - SN-Query-Table - SN-Get-Record - SN-Batch-Create - SN-Batch-Update - SN-Execute-Background-Script rest: - /api/now/table/sys_user - /api/now/table/sys_user_group - /api/now/table/sys_user_grmember - /api/now/table/sys_user_has_role - /api/now/table/sys_user_role native: - Bash - Read complexity: intermediate estimated_time: 15-45 minutes
User Provisioning
Overview
This skill provides comprehensive guidance for ServiceNow user lifecycle management:
- Creating new user accounts with proper attributes
- Assigning roles based on job function
- Managing group memberships
- Handling user deprovisioning and offboarding
- Bulk user operations
When to use: When onboarding new employees, changing user access, or offboarding departing employees.
Who should use this: System administrators, security administrators, and HR system integrators.
Prerequisites
- Roles:
admin,user_admin, orsecurity_admin - Access: sys_user, sys_user_group, sys_user_grmember, sys_user_has_role tables
- Knowledge: Understanding of your organization's role and group structure
- LDAP/SSO: If integrated, understand which attributes are managed externally
Key Tables
| Table | Purpose |
|---|---|
| sys_user | User records |
| sys_user_group | Group definitions |
| sys_user_grmember | Group membership associations |
| sys_user_has_role | Direct role assignments |
| sys_user_role | Role definitions |
| sys_group_has_role | Roles assigned to groups |
Procedure
Phase 1: User Creation
Step 1.1: Gather User Information
Required fields for new user creation:
| Field | Description | Example |
|---|---|---|
| user_name | Unique login ID | jsmith |
| first_name | First name | John |
| last_name | Last name | Smith |
| Email address | john.smith@company.com | |
| employee_number | Employee ID | EMP-12345 |
| department | Department reference | IT Operations |
| manager | Manager reference | Manager's sys_id |
Step 1.2: Check for Existing User
Before creating, verify user doesn't already exist.
Using MCP:
Tool: SN-Query-Table
Parameters:
table_name: sys_user
query: user_name=jsmith^ORemail=john.smith@company.com
fields: sys_id,user_name,email,active
limit: 5
If user exists, proceed to role/group assignment instead.
Step 1.3: Create User Account
Using MCP:
Tool: SN-Create-Record
Parameters:
table_name: sys_user
data:
user_name: jsmith
first_name: John
last_name: Smith
email: john.smith@company.com
employee_number: EMP-12345
title: Software Developer
department: [department_sys_id]
manager: [manager_sys_id]
location: [location_sys_id]
company: [company_sys_id]
phone: "+1-555-123-4567"
mobile_phone: "+1-555-987-6543"
active: true
locked_out: false
password_needs_reset: true
notification: 2 # Email notifications enabled
Using REST API:
POST /api/now/table/sys_user
Content-Type: application/json
{
"user_name": "jsmith",
"first_name": "John",
"last_name": "Smith",
"email": "john.smith@company.com",
"employee_number": "EMP-12345",
"active": "true",
"password_needs_reset": "true"
}
Step 1.4: Set Initial Password
Using MCP (Background Script):
Tool: SN-Execute-Background-Script
Parameters:
script: |
var user = new GlideRecord('sys_user');
user.get('user_name', 'jsmith');
// Generate random password
var password = GlideSecureRandomUtil.getSecureRandomString(16);
user.setDisplayValue('user_password', password);
user.password_needs_reset = true;
user.update();
// Send welcome email (optional)
gs.eventQueue('user.created', user, password, '');
gs.info('User created. Initial password set. User will be prompted to reset on first login.');
description: Set initial password for new user
Phase 2: Role Assignment
Step 2.1: Understand Role Hierarchy
Common ServiceNow roles:
| Role | Description | Typical Users |
|---|---|---|
| itil | ITSM operations | Help desk, technicians |
| admin | Full administrative access | System admins |
| approver_user | Approval capabilities | Managers |
| catalog_admin | Catalog management | Catalog owners |
| knowledge | Knowledge base access | KB contributors |
| asset | Asset management | Asset managers |
| change_manager | Change management | Change managers |
| problem_manager | Problem management | Problem managers |
Step 2.2: Query Available Roles
Find Roles:
Tool: SN-Query-Table
Parameters:
table_name: sys_user_role
query: active=true
fields: sys_id,name,description,suffix
limit: 50
Find Role by Name:
Tool: SN-Query-Table
Parameters:
table_name: sys_user_role
query: name=itil
fields: sys_id,name,description
limit: 1
Step 2.3: Assign Role to User
Direct Role Assignment:
Tool: SN-Create-Record
Parameters:
table_name: sys_user_has_role
data:
user: [user_sys_id]
role: [role_sys_id]
state: active
inherited: false
Assign Multiple Roles (Batch):
Tool: SN-Batch-Create
Parameters:
records:
- table_name: sys_user_has_role
data:
user: [user_sys_id]
role: [itil_role_sys_id]
- table_name: sys_user_has_role
data:
user: [user_sys_id]
role: [knowledge_role_sys_id]
- table_name: sys_user_has_role
data:
user: [u
阅读完整来源 ↗