public static List<string> GetProfileDir(SecurityIdentifier sid)
{
List<string> ret = new List<string>();
//"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-534125731-1308685933-1530606844-1000}"
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(ROOT_PROFILE_KEY))
{
if (key != null)
{
foreach (string keyName in key.GetSubKeyNames())
{
if (keyName.Contains(sid.ToString())) //get the %SID% and %SID%.bak key
{
using(RegistryKey subKey = Registry.LocalMachine.OpenSubKey(string.Format("{0}\\{1}", ROOT_PROFILE_KEY, keyName)))
{
LibraryLogging.Info("ProfileList key found {0}", keyName);
ret.Add(subKey.GetValue("ProfileImagePath", "", RegistryValueOptions.None).ToString());
}
}
}
}
else
{
LibraryLogging.Info("GetProfileDir key {0} not found", ROOT_PROFILE_KEY);
}
}
return ret;
}