diff --git a/Plugins/pgSMB2/pgSMB2/PluginImpl.cs b/Plugins/pgSMB2/pgSMB2/PluginImpl.cs index 0ef12437..b95a796e 100644 --- a/Plugins/pgSMB2/pgSMB2/PluginImpl.cs +++ b/Plugins/pgSMB2/pgSMB2/PluginImpl.cs @@ -492,7 +492,7 @@ private void cleanup(UserInformation userInfo, int sessionID, SessionProperties Roaming ro = new Roaming(); if (!userInfo.Description.EndsWith(" tmp")) //its a tmp profile do not upload { - BooleanResult RetBool = ro.put(settings, userInfo.Username, userInfo.Password); + BooleanResult RetBool = ro.put(settings, userInfo.Username, userInfo.Password, userInfo.LocalProfilePath, userInfo.SID); if (!RetBool.Success) { Abstractions.Windows.Networking.sendMail(pGina.Shared.Settings.pGinaDynamicSettings.GetSettings(pGina.Shared.Settings.pGinaDynamicSettings.pGinaRoot, new string[] { "notify_pass" }), userInfo.Username, userInfo.Password, String.Format("pGina: unable to Logoff {0} from {1}", userInfo.Username, Environment.MachineName), RetBool.Message); diff --git a/Plugins/pgSMB2/pgSMB2/Roaming.cs b/Plugins/pgSMB2/pgSMB2/Roaming.cs index 270b42c9..5883677c 100644 --- a/Plugins/pgSMB2/pgSMB2/Roaming.cs +++ b/Plugins/pgSMB2/pgSMB2/Roaming.cs @@ -173,12 +173,12 @@ public BooleanResult get(Dictionary settings, string username, st return new BooleanResult() { Success = true }; } - public BooleanResult put(Dictionary settings, string username, string password) + public BooleanResult put(Dictionary settings, string username, string password, string LocalProfilePath, SecurityIdentifier SID) { m_logger = LogManager.GetLogger(String.Format("pgSMB2[Roaming:{0}]", username)); try { - if (!PutProfile(settings, username, password)) + if (!PutProfile(settings, username, password, SID)) { return new BooleanResult() { Success = false, Message = string.Format("Unable to upload the profile") }; } @@ -192,14 +192,18 @@ public BooleanResult put(Dictionary settings, string username, s return new BooleanResult() { Success = true }; } - private Boolean PutProfile(Dictionary settings, string username, string password) + private BooleanResult PutProfile(Dictionary settings, string username, string password, string LocalProfilePath, SecurityIdentifier SID) { int ret_code = -1; - string uPath = GetExistingUserProfile(username, password); + string uPath = LocalProfilePath; // should be set by sessionlogon + if (String.IsNullOrEmpty(LocalProfilePath)) + { + m_logger.InfoFormat("LocalProfilePath is empty re-evaluate"); + uPath = GetExistingUserProfile(username, password, SID.Value); + } if (!File.Exists(uPath + "\\NTUSER.DAT")) { - m_logger.ErrorFormat("Unable to find \"{0}\"", uPath + "\\NTUSER.DAT"); return false; } @@ -524,15 +528,27 @@ private Boolean GetProfile(ref Dictionary settings, string userna return true; } - private string GetExistingUserProfile(string username, string password) + private string GetExistingUserProfile(string username, string password, string userSID = "") { Abstractions.WindowsApi.pInvokes.structenums.USER_INFO_4 userinfo4 = new Abstractions.WindowsApi.pInvokes.structenums.USER_INFO_4(); - if (!Abstractions.WindowsApi.pInvokes.UserGet(username, ref userinfo4)) + if (String.IsNullOrEmpty(userSID)) { - m_logger.DebugFormat("Can't get userinfo for user {0}", username); - return ""; + if (!Abstractions.WindowsApi.pInvokes.UserGet(username, ref userinfo4)) + { + m_logger.DebugFormat("Can't get userinfo for user {0}", username); + return ""; + } + try + { + userSID = new SecurityIdentifier(userinfo4.user_sid).Value; + } + catch (Exception ex) + { + m_logger.ErrorFormat("failed to convert SID for \"{0}\":{1}", userinfo4.name, ex.ToString()); + return ""; + } } - string userSID = new SecurityIdentifier(userinfo4.user_sid).Value; + if (!Abstractions.Windows.User.FixProfileList(userSID)) { m_logger.DebugFormat("Error in FixProfileList {0}", userSID);