Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Automating Account Deletion based on LDS log

$
0
0

I am trying to automate ldap account deletion based on an ms lds sync log. Below is a snippet of the last few lines of the log. Currently I just scan the file for the string "ldap error" and an email is generated, and I fix the issue manually.

I would like to capture the offending account name, and automate deletion. The deletion part I am fine with, it's the capturing the offending user part I am having a hard time wrapping my head around. I know some RegExp will be involved. Can anyone point me in the right direction for capturing, in this example, "OFFENDING_USER", and making it a variable that I can pass for deletion? The string will always be found 2 lines prior to the words "Ldap Error Occured" and between CN and the first , (comma).

ProcessingEntry:Page5,Frame1,Entry4,Count1, USN 0

Processing source entry

Processing in-scope entry bc5579502649bf4d8fb4d0090c9647a9.

Modifying target object CN=User1234567,OU=People,DC=BLAH,DC=COM.

Modifying attributes: lastagedchange,

Previous entry took 0 seconds (0, 0) to process

Processing Entry: Page 5, Frame 1, Entry 5, Count 1, USN 0

Processing source entry

Processing in-scope entry 6ddbcc305b04eb40851869a43efaf232.

Modifying target object CN=User123456,OU=PhP-People,OU=ANOTHEROU,DC=BLAH,DC=COM.

Modifying attributes: lastagedchange,

Previous entry took 0 seconds (16, 0) to process

Processing Entry: Page 5, Frame 1, Entry 6, Count 1, USN 0

Processing source entry

Processing in-scope entry 99eb239bce38c24183c9b3cacbeb2e43.

Modifying target object CN=User12345,OU=Contractors,OU=Non-Employees,DC=BLAH,DC=COM.

Modifying attributes: description, lastagedchange,

Previous entry took 0 seconds (0, 0) to process

Processing Entry: Page 5, Frame 1, Entry 7, Count 1, USN 0

Processing source entry

Processing in-scope entry 3b630de48c7b104a8a2d7c4e3c93edde.

Adding target object CN=OFFENDING_USER,OU=CloudApp,OU=EXT,DC=BLAH,DC=COM.

Adding attributes: sourceobjectguid, objectClass, sn, instanceType, displayName, userAccountControl, sAMAccountName, userPrincipalName, mail, lastagedchange,

Ldap error occured. ldap_add_sW: Attribute Or Value Exists.

Extended Info: 0000217B: AtrErr: DSID-030507E7, #1: 0: 0000217B: DSID-030507E7, problem 1006 (ATT_OR_VALUE_EXISTS), data 0, Att 90290 (userPrincipalName) .

Ldap error occured. ldap_add_sW: Attribute Or Value Exists.

Extended Info: 0000217B: AtrErr: DSID-030507E7, #1: 0: 0000217B: DSID-030507E7, problem 1006 (ATT_OR_VALUE_EXISTS), data 0, Att 90290 (userPrincipalName) .

Saving Configuration File on OU=CLOUDAPP,OU=EXT,DC=BLAH,DC=COM

Saved configuration file.


Viewing all articles
Browse latest Browse all 6937

Trending Articles