Add Computer Account as memberOf Windows Authorization Access Group.

First, I will be running this code on a Windows 2003 Server machine, using .net 2.0.

Essentially I just need to add the Windows Authorization Access Group to a Computer Account. I was attempting to do this with DirectoryServices, but I had no luck. It informed me in the form of an error that the server was "unwilling" to perform the operation.

And if I try to do it using ADSI Edit (this was just to test, I need to do it programmatically not using some GUI) I was informed that  "Access to the attribute is not permitted because the attribute is owned by the Security Accounts Manager (SAM)."

The code snippet I have attached illustrates the end-result I want, but I cannot do it using the code I attached, it throws the "unwilling" error. So if someone could assist me that would be great.
DirectoryEntry entry = new DirectoryEntry("LDAP://CN=SomeComputerName,CN=Computers,DC=SomeDomainName,DC=com");
entry.Properties["memberOf"].Add("CN=Windows Authorization Access Group,CN=Builtin,DC=SomeDomainName,DC=com");

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Drifter88zxtWAuthor Commented:
I have found the solution myself, I was performing the operation backwards. It seems because of the was AD handles the references one must add the computer to the group entry's "member" attribute as follows:

DirectoryEntry entry = new DirectoryEntry("LDAP://CN=Windows Authorization Access Group,CN=Builtin,DC=SomeDomain,DC=com");

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.