Nate
Nate

Reputation: 231

How to programmatically add UPN Suffix in Active Directory Domains and Trusts in .NET?

I think the Question title basically sums it up. Manually, I would open Active Directory Domains and Trusts, right click on top node in Explorer tree, and add domain UPN suffix.

Upvotes: 1

Views: 2008

Answers (1)

Brian Desmond
Brian Desmond

Reputation: 4503

Sure. You need to modify the upnSuffixes attribute of the CN=Partitions,CN=Configuration,DC=ForestRootDomain,DC=com object. Keep in mind there's a rough limit of about 1300 values stored in there.

Something like this should work - just wrote the code in the textbox though so might need a bit of tweaking:

DirectoryEntry partitionsContainer = new DirectoryEntry("LDAP://CN=Partitions,CN=Configuration,DC=ForestRootDomain,DC=com");
partitionsContainer["upnSuffixes"].Add("foosuffix.net");
partitionsContainer.CommitChanges();

Upvotes: 4

Related Questions