Jenkins automation - Disable AD User

This guide documents how to send data from Torii to Jenkins for complex automation workflows. There are a variety of complex onboarding, offboarding, and license management use cases that can be automated with Jenkins via webhook triggers.

In this section, we will be detailing how to disable a user via Jenkins automation code.

In this section, we will be detailing how to disable an AD user using Jenkins automation code.

More information about Jenkins webhook triggers can be found here.

Custom Action Configuration

Method : POST

URL : <your_jenkins_webhook_url>

Query Parameters

ParameterVariable Mapping

Headers

HeaderValue
userinfo[Trigger.User.Email]

Body

You will need to execute two Powershell commands with the Jenkins automation code to disable a user. These Powershell commands are provided below.

First, you will lookup the user's AD login ID (sAMAccountname) using the passed in email address.

Then, use the sAMAccountname to disable the user account.

Get-ADUser

Get-ADUser -Filter {Emailaddress -eq '[email protected]'}

Disable-ADAccount

Disable-ADAccount -Identity <your_returned_user_id_from_Get-ADUser>

👍

Congratulations! At this point you should have successfully disabled the user account using the Jenkins automation code. > 👍 Congratulations! At this point you should have successfully disabled the AD user account via Jenkins automation code.

📘

Tips

You can add different attributes based on requirements for your specific use case.