Playbook to search AD expired accounts and delete them

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Playbook to search AD expired accounts and delete them

L2 Linker

Hi,

I am trying to create a playbook that

1) Searches for expired accounts in AD

2) Retrieves the sAMAccountName, Display name and expired date

3) Delete the accounts 

4) Sent an email notification with the details of the accounts deleted.

 

I created the ldap query for the same and one factor was to get the current time to use in the query.

There is a function call DateTimetoADTime in XSOAR which can be used for that.

 

The LDAP query is as follows

(&(objectCategory=person)(objectClass=user)(!accountExpires=9223372036854775807)(!accountExpires=0))

 

I get the current date in AD format using

DatetimetoADTime days_ago=0

 

I append to the LDAP query above to get the result using ad-search (xsoar function) like so

(&(objectCategory=person)(objectClass=user)(!accountExpires=9223372036854775807)(!accountExpires=0))(accountExpires<=<output given from DatetimetoADTime>)

 

This works in the playground where I get the display names only though.

 

I tried to make a playbook out of this but I am stuck at the step after using the DateTimetoADTime, how do I give the value as input to ad-search to retrieve the users and also get the details of each user (sAMAccountName, Display name and expired date), then give the same as output to be deleted?

 

Thanks in advance

 

1 accepted solution

Accepted Solutions

L5 Sessionator

Hi @pottapitot, you can use the extend context option to save the data to the context in the DatetimetoADTime step. Then use that context key token in the following step. Use "data=" to dump all command output into the context key. For more information refer - https://xsoar.pan.dev/docs/playbooks/playbooks-extend-context

 

Screen Shot 2022-06-20 at 12.32.03 pm.png

 

 

View solution in original post

2 REPLIES 2

L5 Sessionator

Hi @pottapitot, you can use the extend context option to save the data to the context in the DatetimetoADTime step. Then use that context key token in the following step. Use "data=" to dump all command output into the context key. For more information refer - https://xsoar.pan.dev/docs/playbooks/playbooks-extend-context

 

Screen Shot 2022-06-20 at 12.32.03 pm.png

 

 

Hi @jfernandes1 ,

 

That was exactly what I was looking for. Thanks alot.

 

Cheers

  • 1 accepted solution
  • 2388 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!