I have a program that does just that. Here is the relevant piece of code:
NTAccount ntuser = new NTAccount(strUser); SecurityIdentifier sID = (SecurityIdentifier) ntuser.Translate(typeof(SecurityIdentifier)); strSID = sID.ToString();
You will need to import two namespaces:
using System.DirectoryServices; using System.Security.Principal;
Hope this helps.
Then use Registry.Users.SetValue with SID string \ path to set the registry value.
This may not work properly if you are editing a profile with a profile disabled, especially a roaming profile.
deutschZuid
source share