Forever learning, turning real-world problems into real IT solutions.

Clearing SIDHistory in Active Directory with PowerShell: Unlock Your Admin Powers and Defeat ‘Access is Denied’ 0x5

Picture this: You’re migrating a user from one Active Directory (AD) domain to another. All seems to be going well until you hit a roadblock: the dreaded error message “The maximum size of an object has been exceeded.” Let’s break down how to solve this, step by step, with a dash of humor and a ton of technical insight.

Identifying the Root Cause: SID History Strikes Again!

When dealing with Active Directory migrations, there’s one attribute that loves to throw a wrench in your well-oiled machine: SIDHistory. In this case, the error was triggered because the SIDHistory attribute had grown way too large, thanks to multiple migrations over the years. Think of it like your email inbox after 10 years without clearing out spam—it gets bloated!

  • SIDHistory: This attribute stores the Security Identifiers (SIDs) of a user from their previous domains. Handy for keeping access during a migration but can quickly become oversized if left unchecked.
  • The problem: Users with an excessively large SIDHistory attribute exceeded the maximum object size that AD could handle.

Access Denied: ADSIEdit and the Locked SIDHistory

Now, you might think, “No problem, I’ll just fire up ADSIEdit and clean up the SIDHistory manually.” But when you try, you get another lovely error:

“Operation failed. Error code: 0x5 Access is denied. PROBLEM 4003 INSUFF_ACCESS_RIGHTS”

An error message of Access is denied 0x5 when attempting to modify sidHistory attribute

Why? Well, SIDHistory is a system-controlled attribute. Even with administrative rights, AD locks you out from directly modifying this attribute.

The Power of PowerShell: Cleaning Up SIDHistory

Here’s how I resolved the issue:

  1. Set up the lab: Always a good practice when you’re testing something new or potentially destructive.
  2. Run the PowerShell command: To remove all the SIDs from the SIDHistory attribute, I used the following command:
PowerShell
Get-ADUser migUser -Properties sidhistory | ForEach-Object {Set-ADUser $_ -Remove @{sidhistory = $_.sidhistory.value}}
  1. This command retrieves the user (in this case, migUser) and removes all SIDHistory entries.
  2. It works like a charm because it handles the system-controlled attribute in a way that AD approves of—no more access denied errors.

Mission Accomplished: Migrating Users with a Clean Slate

Once we removed the bloated SIDHistory, we were able to successfully migrate the user to the new domain without any issues. And since the customer wanted the users’ SIDs migrated to the new domain, we ensured that their SIDHistory was clear to start fresh.

Key Takeaways

  • Watch out for large SIDHistory attributes: If a user has been migrated multiple times, this attribute can cause migration failures. There are other attributes that can also impact this, like mSMQSignCertificates, mSMQDigests, UserCertificates, etc.
  • ADSIEdit isn’t always your friend: Don’t expect to edit system-controlled attributes like SIDHistory directly, even as an admin. There are other ways to edit system-controlled attributes that I will cover in a future blog post.
  • PowerShell to the rescue: Use the right tools for the job. PowerShell is a powerful ally in dealing with AD challenges.

Next time you face an AD migration, remember to check the size of the SIDHistory attribute, especially for users with a complex migration history. Share your own war stories with Active Directory in the comments. Let’s learn together!

Happy migrating, fellow techies!

References

Alexander Mora Avatar

Leave a Reply

Your email address will not be published. Required fields are marked *