diff --git a/c_micasad/cache/SecretStore.cs b/c_micasad/cache/SecretStore.cs index afee87c4..5012b00a 100644 --- a/c_micasad/cache/SecretStore.cs +++ b/c_micasad/cache/SecretStore.cs @@ -117,6 +117,15 @@ namespace sscs.cache internal bool StartPersistenceByDesktopPasswd(string desktopPasswd) { + CSSSLogger.DbgLog("StartPersistenceByDesktopPasswd - Called"); + // make sure we have a user home directory + if (GetUserHomeDirectory() == null || GetUserHomeDirectory().Length < 1) + { + CSSSLogger.DbgLog("StartPersistenceByDesktopPasswd - No Home directory yet"); + return false; + } + + try { byte[] baPasscode; @@ -137,6 +146,7 @@ namespace sscs.cache */ } CSSSLogger.DbgLog(CSSSLogger.GetExecutionPath(this) + " Store is already persistent"); + CSSSLogger.DbgLog("StartPersistenceByDesktopPasswd - Started"); return true; } diff --git a/c_micasad/common/SessionManager.cs b/c_micasad/common/SessionManager.cs index 93b1043d..607ac91a 100644 --- a/c_micasad/common/SessionManager.cs +++ b/c_micasad/common/SessionManager.cs @@ -130,6 +130,14 @@ namespace sscs.common { User user = (User)sessionTable[userId]; SecretStore ss = user.GetSecretStore(); + // start persistent if not going yet + if (!ss.IsStorePersistent()) + { + string sDesktopPWD = ss.GetDesktopPasswd(); + if (sDesktopPWD != null) + ss.StartPersistenceByDesktopPasswd(sDesktopPWD); + } + mutex.ReleaseMutex(); return ss; } diff --git a/c_micasad/common/WinUser.cs b/c_micasad/common/WinUser.cs index 1a1a9d0d..7f42007c 100644 --- a/c_micasad/common/WinUser.cs +++ b/c_micasad/common/WinUser.cs @@ -37,9 +37,10 @@ namespace sscs.common */ override internal string GetUserHomeDir() { - - if (m_sUserHome.Length < 1) + CSSSLogger.DbgLog("WinUser:GetUserHomeDir - Entered"); + if (m_sUserHome == null || m_sUserHome.Length < 1) { + CSSSLogger.DbgLog("WinUser:GetUserHomeDir is empty"); //Console.WriteLine("read registry"); // get the users home drive and homepath from the registry // @@ -47,14 +48,21 @@ namespace sscs.common // look up Profile path // [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21-1757981266-436374069-725345543-1006] + CSSSLogger.DbgLog("Reading Reg: SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\" + sSIDString); string sProfile = ReadRegKey(Registry.LocalMachine, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\" + sSIDString, "ProfileImagePath"); - m_sUserHome = sProfile; + + if (sProfile == null) + CSSSLogger.DbgLog("WinUser:GetUserHomeDir get Profile return null"); + else + m_sUserHome = sProfile; //string sHomeDrive = ReadRegKey(Registry.Users, sSIDString+"\\Volatile Environment", "HOMEDRIVE"); //string sHomeDir = ReadRegKey(Registry.Users, sSIDString+"\\Volatile Environment", "HOMEPATH"); //m_sUserHome = sHomeDrive+sHomeDir; //Console.WriteLine("Homedir: "+ m_sUserHome); } + + CSSSLogger.DbgLog("WinUser:GetUserHomeDir - Exited: "+m_sUserHome); return m_sUserHome; } diff --git a/c_micasad/common/WinUserIdentifier.cs b/c_micasad/common/WinUserIdentifier.cs index 19e458ca..5b90039e 100644 --- a/c_micasad/common/WinUserIdentifier.cs +++ b/c_micasad/common/WinUserIdentifier.cs @@ -14,12 +14,14 @@ namespace sscs.common this.uidHigh = uidHighPart; this.m_sSID = sSID; } + internal WinUserIdentifier(int uidLowPart, int uidHighPart) { this.uidLow = uidLowPart; this.uidHigh = uidHighPart; } + internal string GetSID() { return m_sSID; @@ -29,7 +31,16 @@ namespace sscs.common { WinUserIdentifier u = (WinUserIdentifier)obj; if ((u.uidLow == uidLow) && (u.uidHigh == uidHigh)) + { + // we have a match, set the SID if we can + if ((this.m_sSID.Length < 1) && (u.GetSID().Length>0)) + { + CSSSLogger.DbgLog("******** WinUserIdentifier: Updating the SID *********"); + this.m_sSID = u.GetSID(); + } + return true; + } else return false; }