put() public method

public put ( string>.Dictionary settings, string username, string password, string LocalProfilePath, System.Security.Principal.SecurityIdentifier SID ) : BooleanResult
settings string>.Dictionary
username string
password string
LocalProfilePath string
SID System.Security.Principal.SecurityIdentifier
return pGina.Shared.Types.BooleanResult
Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        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();
            }
        }