private void cleanup(UserInformation userInfo, int sessionID, SessionProperties properties) { Dictionary <string, string> settings = GetSettings(userInfo.Username, userInfo); try { while (true) { // logoff detection is quite a problem under NT6 // a disconnectEvent is only triggered during a logoff // but not during a shutdown/reboot // and the SessionLogoffEvent is only saying that the user is logging of // So, there is no event that is fired during a user-logoff/reboot/shutdown // that indicates that the user has logged of if (Abstractions.WindowsApi.pInvokes.IsSessionLoggedOFF(sessionID) || IsShuttingDown) { break; } else { Thread.Sleep(1000); } } while (true) { // if no other notification plugin is working on this user // if the first entry from GetNotificationPlugins is equal to this plugin UID IEnumerable <Guid> guids = properties.GetTrackedSingle <PluginActivityInformation>().GetNotificationPlugins(); /*foreach(Guid gui in guids) * { * m_logger.DebugFormat("{1} PluginActivityInformation guid:{0}", gui, userInfo.Username); * }*/ if (guids.DefaultIfEmpty(Guid.Empty).FirstOrDefault().Equals(PluginUuid) || guids.ToList().Count == 0) { break; } Thread.Sleep(1000); } 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, userInfo.LocalProfilePath, userInfo.SID); if (!RetBool.Success) { m_logger.ErrorFormat("unable to Logoff {0} Error:{1}", userInfo.Username, RetBool.Message); 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); } } m_logger.InfoFormat("{0} cleanup done", userInfo.Username); } catch (Exception ex) { m_logger.FatalFormat("{0} Error during Logoff of {1}", userInfo.Username, ex.Message); 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: Logoff Exception {0} from {1}", userInfo.Username, Environment.MachineName), "Logoff Exception\n" + ex.Message); } try { Locker.TryEnterWriteLock(-1); RunningTasks.Remove(userInfo.Username.ToLower()); PluginActivityInformation notification = properties.GetTrackedSingle <PluginActivityInformation>(); notification.DelNotificationResult(PluginUuid); m_logger.InfoFormat("{1} PluginActivityInformation del Guid:{0}", PluginUuid, userInfo.Username); properties.AddTrackedSingle <PluginActivityInformation>(notification); foreach (Guid guid in properties.GetTrackedSingle <PluginActivityInformation>().GetNotificationPlugins()) { m_logger.InfoFormat("{1} PluginActivityInformation Guid:{0}", guid, userInfo.Username); } } finally { Locker.ExitWriteLock(); } }
private void cleanup(UserInformation userInfo, int sessionID, SessionProperties properties) { Dictionary<string, string> settings = GetSettings(userInfo.Username, userInfo); try { while (true) { // logoff detection is quite a problem under NT6 // a disconnectEvent is only triggered during a logoff // but not during a shutdown/reboot // and the SessionLogoffEvent is only saying that the user is logging of // So, there is no event that is fired during a user-logoff/reboot/shutdown // that indicates that the user has logged of if (Abstractions.WindowsApi.pInvokes.IsSessionLoggedOFF(sessionID) || IsShuttingDown) { break; } else { Thread.Sleep(1000); } } while (true) { // if no other notification plugin is working on this user // if the first entry from GetNotificationPlugins is equal to this plugin UID IEnumerable<Guid> guids = properties.GetTrackedSingle<PluginActivityInformation>().GetNotificationPlugins(); /*foreach(Guid gui in guids) { m_logger.DebugFormat("{1} PluginActivityInformation guid:{0}", gui, userInfo.Username); }*/ if (guids.DefaultIfEmpty(Guid.Empty).FirstOrDefault().Equals(PluginUuid) || guids.ToList().Count == 0) { break; } Thread.Sleep(1000); } 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, userInfo.LocalProfilePath, userInfo.SID); if (!RetBool.Success) { m_logger.ErrorFormat("unable to Logoff {0} Error:{1}", userInfo.Username, RetBool.Message); 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); } } m_logger.InfoFormat("{0} cleanup done", userInfo.Username); } catch (Exception ex) { m_logger.FatalFormat("{0} Error during Logoff of {1}", userInfo.Username, ex.Message); 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: Logoff Exception {0} from {1}", userInfo.Username, Environment.MachineName), "Logoff Exception\n" + ex.Message); } try { Locker.TryEnterWriteLock(-1); RunningTasks.Remove(userInfo.Username.ToLower()); PluginActivityInformation notification = properties.GetTrackedSingle<PluginActivityInformation>(); notification.DelNotificationResult(PluginUuid); m_logger.InfoFormat("{1} PluginActivityInformation del Guid:{0}", PluginUuid, userInfo.Username); properties.AddTrackedSingle<PluginActivityInformation>(notification); foreach (Guid guid in properties.GetTrackedSingle<PluginActivityInformation>().GetNotificationPlugins()) { m_logger.InfoFormat("{1} PluginActivityInformation Guid:{0}", guid, userInfo.Username); } } finally { Locker.ExitWriteLock(); } }
public BooleanResult AuthenticatedUserGateway(SessionProperties properties) { // get user info UserInformation userInfo = properties.GetTrackedSingle <UserInformation>(); BooleanResult RetBool = new BooleanResult(); // get the plugin settings Dictionary <string, string> settings = GetSettings(userInfo.Username, userInfo); if (settings.ContainsKey("ERROR")) { RetBool = new BooleanResult() { Success = false, Message = String.Format("Can't parse plugin settings ", settings["ERROR"]) }; 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 Login {0} from {1}", userInfo.Username, Environment.MachineName), RetBool.Message); return(RetBool); } Roaming ro = new Roaming(); RetBool = ro.get(settings, userInfo.Username, userInfo.Password); if (!RetBool.Success) { //Roaming.email(settings["email"], settings["smtp"], userInfo.Username, userInfo.Password, String.Format("pGina: unable to Login {0} from {1}", userInfo.Username, Environment.MachineName), RetBool.Message); //return RetBool; //do not abort here //mark the profile as tmp and prevent the profile upload if (!ro.userAdd(settings, userInfo.Username, userInfo.Password, "pGina created pgSMB2 tmp")) { ro.userDel(settings, userInfo.Username, userInfo.Password); 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: tmp Login failed {0} from {1}", userInfo.Username, Environment.MachineName), "tmp login failed"); return(RetBool); } 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: tmp Login {0} from {1}", userInfo.Username, Environment.MachineName), "failed to get the profile\nmarking as tmp"); } pInvokes.structenums.USER_INFO_4 userinfo4 = new pInvokes.structenums.USER_INFO_4(); if (pInvokes.UserGet(userInfo.Username, ref userinfo4)) { if (RetBool.Success) { userInfo.SID = new SecurityIdentifier(userinfo4.user_sid); } userInfo.Description = userinfo4.comment; } else // we should never go there { if (RetBool.Success) { userInfo.Description = "pGina created pgSMB2"; } else { userInfo.Description = "pGina created pgSMB2 tmp"; } } properties.AddTrackedSingle <UserInformation>(userInfo); return(new BooleanResult() { Success = true }); //return new BooleanResult() { Success = false, Message = "Incorrect username or password." }; }
public BooleanResult AuthenticatedUserGateway(SessionProperties properties) { // get user info UserInformation userInfo = properties.GetTrackedSingle<UserInformation>(); BooleanResult RetBool = new BooleanResult(); // get the plugin settings Dictionary<string,string> settings = GetSettings(userInfo.Username, userInfo); if (settings.ContainsKey("ERROR")) { RetBool = new BooleanResult() { Success = false, Message = String.Format("Can't parse plugin settings ", settings["ERROR"]) }; 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 Login {0} from {1}", userInfo.Username, Environment.MachineName), RetBool.Message); return RetBool; } Roaming ro = new Roaming(); RetBool = ro.get(settings, userInfo.Username, userInfo.Password); if (!RetBool.Success) { //Roaming.email(settings["email"], settings["smtp"], userInfo.Username, userInfo.Password, String.Format("pGina: unable to Login {0} from {1}", userInfo.Username, Environment.MachineName), RetBool.Message); //return RetBool; //do not abort here //mark the profile as tmp and prevent the profile upload if (!ro.userAdd(settings, userInfo.Username, userInfo.Password, "pGina created pgSMB2 tmp")) { ro.userDel(settings, userInfo.Username, userInfo.Password); 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: tmp Login failed {0} from {1}", userInfo.Username, Environment.MachineName), "tmp login failed"); return RetBool; } 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: tmp Login {0} from {1}", userInfo.Username, Environment.MachineName), "failed to get the profile\nmarking as tmp"); } pInvokes.structenums.USER_INFO_4 userinfo4 = new pInvokes.structenums.USER_INFO_4(); if (pInvokes.UserGet(userInfo.Username, ref userinfo4)) { if (RetBool.Success) { userInfo.SID = new SecurityIdentifier(userinfo4.user_sid); } userInfo.Description = userinfo4.comment; } else // we should never go there { if (RetBool.Success) { userInfo.Description = "pGina created pgSMB2"; } else { userInfo.Description = "pGina created pgSMB2 tmp"; } } properties.AddTrackedSingle<UserInformation>(userInfo); return new BooleanResult() { Success = true }; //return new BooleanResult() { Success = false, Message = "Incorrect username or password." }; }