I was using the APIs NetUserAdd and NetUserSetGroups to add a user account and associate it with a group to a computer. Not much later I found an example capable of doing the same thing (adding a user, associating him with a group) using System.DirectoryServices
namespace and DirectoryEntry
object.
Now I need to add policies to that new account and am faced with a similar problem. I can use the LsaOpenPolicy
and LsaAddAccountRights
APIs to add a policy to and account, but I d prefer to use .NET objects and methods.
My question, is/are there object methods in the .NET framework to add and/or modify user account policy settings, and if so what are the names of those objects or methods?
Also an example of usage would be appreciated.
Specifically, I am looking to add the "SeServiceLogonRight", otherwise known as the log in as a service right, to a new user account.