private static string GetStoreDisplayName(WindowsStoreType storeType, string serviceNameOrUserSid, string storeName)
{
int index = storeName.LastIndexOf('\\');
if (index != -1)
{
storeName = storeName.Substring(index+1);
}
if (storeType == WindowsStoreType.LocalMachine)
{
return Utils.Format("LocalMachine\\{0}", storeName);
}
if (storeType == WindowsStoreType.CurrentUser)
{
return Utils.Format("CurrentUser\\{0}", storeName);
}
if (storeType == WindowsStoreType.Service)
{
return Utils.Format("{0}\\{1}", serviceNameOrUserSid, storeName);
}
if (storeType == WindowsStoreType.User)
{
SecurityIdentifier sid = new SecurityIdentifier(serviceNameOrUserSid);
string userName = sid.Translate(typeof(NTAccount)).ToString();
index = userName.LastIndexOf('\\');
if (index != -1)
{
userName = userName.Substring(index+1);
}
return Utils.Format("{0}\\{1}", userName, storeName);
}
return storeName;
}