Пример #1
0
        /// <summary>
        /// Reperimento configurazioni LDAP impostate per un utente
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public static LdapUserConfig GetLdapUserConfigByName(string userName)
        {
            LdapUserConfig config = null;

            // Configurazione per determinare se è attiva la sincronizzazione delle utenze docspa con le utenze ldap
            bool ldapIntegrationActive = LdapConfigurations.LdapIntegrationActivated;

            if (ldapIntegrationActive)
            {
                DocsPaDB.Query_DocsPAWS.Ldap ldapDbServices = new DocsPaDB.Query_DocsPAWS.Ldap();

                config = ldapDbServices.GetLdapUserConfigByName(userName);
            }

            if (config == null)
            {
                config = new LdapUserConfig();
            }

            return(config);
        }
Пример #2
0
        /// <summary>
        /// Reperimento delle informazioni di configurazione ldap per una singolo utente
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public DocsPaVO.Ldap.LdapUserConfig GetLdapUserConfigByName(string userName)
        {
            try
            {
                DocsPaVO.Ldap.LdapUserConfig info = null;

                using (DocsPaDB.DBProvider dbProvider = new DBProvider())
                {
                    DocsPaUtils.Query queryDef = DocsPaUtils.InitQuery.getInstance().getQuery("S_GET_LDAP_USER_CONFIG_BY_NAME");
                    queryDef.setParam("userName", userName);

                    string commandText = queryDef.getSQL();
                    logger.Debug(commandText);

                    using (IDataReader reader = dbProvider.ExecuteReader(commandText))
                    {
                        if (reader.Read())
                        {
                            info = new LdapUserConfig
                            {
                                LdapIdSync      = DocsPaUtils.Data.DataReaderHelper.GetValue <string>(reader, "LDAP_ID_SYNC", true, string.Empty),
                                LdapSyncronized = (!string.IsNullOrEmpty(DocsPaUtils.Data.DataReaderHelper.GetValue <string>(reader, "LDAP_ID_SYNC", true, string.Empty)) &&
                                                   (DocsPaUtils.Data.DataReaderHelper.GetValue <string>(reader, "LDAP_NEVER_SYNC", true, "0") == "0")),
                                LdapAuthenticated = (DocsPaUtils.Data.DataReaderHelper.GetValue <string>(reader, "LDAP_AUTHENTICATED", true, "0") == "1")
                            };

                            //if (info.LdapAuthenticated)
                            //{
                            //    info.LdapUserConfigSettings = new LdapConfig
                            //    {
                            //        LdapIntegrationActive = true,
                            //        ServerName = DocsPaUtils.Data.DataReaderHelper.GetValue<string>(reader, "SERVER_NAME", true, string.Empty),
                            //        GroupDN = DocsPaUtils.Data.DataReaderHelper.GetValue<string>(reader, "GROUP_DN", true, string.Empty)
                            //    };

                            //    if (string.IsNullOrEmpty(info.LdapUserConfigSettings.ServerName) ||
                            //        string.IsNullOrEmpty(info.LdapUserConfigSettings.GroupDN))
                            //    {
                            //        using (Utenti userDb = new Utenti())
                            //        {
                            //            string idAmm;

                            //            // Reperimento id amministrazione per l'utente
                            //            userDb.GetIdAmmUtente(out idAmm, userName);

                            //            LdapConfig adminConfig = GetLdapConfig(idAmm);
                            //            info.LdapUserConfigSettings.ServerName = adminConfig.ServerName;
                            //            info.LdapUserConfigSettings.GroupDN = adminConfig.GroupDN;
                            //        }
                            //    }
                            //}
                        }
                    }
                }

                return(info);
            }
            catch (Exception ex)
            {
                string errorMessage = "Errore nel reperimento delle configurazione LDAP per l'utente";

                logger.Debug(errorMessage, ex);
                throw new ApplicationException(errorMessage, ex);
            }
        }