Ejemplo n.º 1
0
    public bool Display_ViewConfiguration()
    {
        m_refUserApi = new UserAPI();
            m_refSiteApi = new SiteAPI();
            AppImgPath = m_refUserApi.AppImgPath;
            AppName = m_refUserApi.AppName;
            RegisterResources();
            setting_data = m_refSiteApi.GetSiteVariables(m_refUserApi.UserId);
            mapping_data = m_refUserApi.GetADMapping(m_refUserApi.UserId, "userprop", 1, 0, 1);
            group_data = m_refUserApi.GetUserGroupById(1);
            sync_data = m_refUserApi.GetADStatus();
            //domain_data = m_refUserApi.GetDomains(1, 0)
            AdValid = setting_data.AdValid; //CBool(siteVars("AdValid"))
            ViewToolBar();
            //VERSION
            versionNumber.InnerHtml = m_refMsg.GetMessage("version") + " " + m_refSiteApi.Version + " " + m_refSiteApi.ServicePack;
            //BUILD NUMBER
            buildNumber.InnerHtml = "<i>(" + m_refMsg.GetMessage("build") + m_refSiteApi.BuildNumber + ")</i>";

            licenseMessageContainer.Visible = false;
            if (!(AdValid))
            {
                TR_domaindetail.Visible = false;
                licenseMessageContainer.Visible = true;
                licenseMessage.InnerHtml = m_refMsg.GetMessage("entrprise license with AD required msg");
            }
            else
            {
                if ((sync_data.SyncUsers) || (sync_data.SyncGroups) || (sync_data.SyncRelationships) || (sync_data.DeSyncUsers) || (sync_data.DeSyncGroups))
                {
                    if (setting_data.ADAuthentication == 1)
                    {
                        ltr_status.Text = "<a href=\"adreports.aspx?action=ViewAllReportTypes\">" + m_refMsg.GetMessage("ad enabled not configured") + "</a>";
                    }
                    else
                    {
                        ltr_status.Text = "<a href=\"adreports.aspx?action=ViewAllReportTypes\">" + m_refMsg.GetMessage("ad disabled not configured") + "</a>";
                    }
                }
                else
                {sync.Visible  =false;

                }
                if (setting_data.IsAdInstalled)
                {
                    installed.InnerHtml = m_refMsg.GetMessage("active directory installed") + "&nbsp;";
                }
                else
                {
                    installed.InnerHtml = m_refMsg.GetMessage("active directory not installed") + "&nbsp;";
                }
                TD_flag.InnerHtml = m_refMsg.GetMessage("active directory authentication flag");
                if (setting_data.ADAuthentication == 1)
                {
                    TD_flagenabled.InnerHtml = m_refMsg.GetMessage("AD enabled");
                }
                else if (setting_data.ADAuthentication == 2)
                {
                    TD_flagenabled.InnerHtml = m_refMsg.GetMessage("LDAP enabled");
                }
                else
                {
                    TD_flagenabled.InnerHtml = m_refMsg.GetMessage("disabled");
                }
                TD_dirflag.InnerHtml = m_refMsg.GetMessage("active directory flag");
                if (setting_data.ADIntegration)
                {
                    TD_intflag.InnerHtml = m_refMsg.GetMessage("enabled");
                }
                else
                {
                    TD_intflag.InnerHtml = m_refMsg.GetMessage("disabled");
                }
                TD_autouser.InnerHtml = m_refMsg.GetMessage("auto add user flag");
                if (setting_data.ADAutoUserAdd)
                {
                    TD_autouserflag.InnerHtml = m_refMsg.GetMessage("enabled");
                }
                else
                {
                    TD_autouserflag.InnerHtml = m_refMsg.GetMessage("disabled");
                }

                lgd_autoAddType.InnerHtml = m_refMsg.GetMessage("lbl auto add header");
                autoAddTypeProperty.InnerHtml = m_refMsg.GetMessage("lbl auto add user type");
                if (setting_data.ADAutoUserAddType == Ektron.Cms.Common.EkEnumeration.AutoAddUserTypes.Member)
                {
                    autoAddTypeValue.InnerHtml = m_refMsg.GetMessage("lbl member");
                }
                else
                {
                    autoAddTypeValue.InnerHtml = m_refMsg.GetMessage("lbl author");
                }

                TD_autogroup.InnerHtml = m_refMsg.GetMessage("auto add user to group flag");

                if (setting_data.ADAutoUserToGroup)
                {
                    TD_autogroupflag.InnerHtml = m_refMsg.GetMessage("enabled");
                }
                else
                {
                    TD_autogroupflag.InnerHtml = m_refMsg.GetMessage("disabled");
                }
                userProperty.InnerHtml = m_refMsg.GetMessage("user property mapping title");
                TD_cmstitle.InnerHtml = m_refMsg.GetMessage("cms property title");
                TD_dirproptitle.InnerHtml = m_refMsg.GetMessage("active directory property title");
                int i = 0;
                if (!(mapping_data == null))
                {
                    System.Text.StringBuilder result = new System.Text.StringBuilder();
                    for (i = 0; i <= mapping_data.Length - 1; i++)
                    {
                        result.Append("<tr>");
                        result.Append("<td class=\"label\">" + GetResourseText(mapping_data[i].CmsName) + ":</td>");
                        result.Append("<td class=\"readOnlyValue\">" + mapping_data[i].AdName + "</td>");
                        result.Append("<tr>");
                    }
                    mapping_list.Text = result.ToString();
                }
                adminGroupMap.InnerHtml = m_refMsg.GetMessage("cms admin group map");
                TD_grpnameval.InnerHtml = group_data.GroupName;
                TD_grpDomainVal.InnerHtml = group_data.GroupDomain;
                domain.InnerHtml = m_refMsg.GetMessage("domain title") + ":";
                //If (domain_data.Length = 0) Then
                //domainValue.InnerHtml += "<font color=""red""><strong>" & m_refMsg.GetMessage("generic no domains found") & " " & m_refMsg.GetMessage("generic check ad config msg") & "</strong></font>"
                //Else
                if (setting_data.ADDomainName == "")
                {
                    domainValue.InnerHtml += m_refMsg.GetMessage("all domain select caption");
                }
                else if (setting_data.ADAuthentication == 2)
                {
                    domainValue.InnerHtml += m_refMsg.GetMessage("all domain select caption");
                }
                else
                {
                    domainValue.InnerHtml += setting_data.ADDomainName;
                }
                //End If
            }
            return false;
    }
Ejemplo n.º 2
0
    private bool Display_EditConfiguration()
    {
        string[] arrOrg;
            string[] arrItem;
            long arrCount;
            string[] arrDomain;
            long arrCount2;
            string[] arrOrg2;
            bool isUnit = false;
            string[] arrServer;
            string[] arrLDAPDomain;
            string strLDAPDomain = "";
            string[] arrLDAPDomainElement;
            bool first = true;
            string adselectedstate = "";

            m_refUserApi = new UserAPI();
            m_refSiteApi = new SiteAPI();
            AppImgPath = m_refUserApi.AppImgPath;
            AppName = m_refUserApi.AppName;
            setting_data = m_refSiteApi.GetSiteVariables(-1);
            mapping_data = m_refUserApi.GetADMapping(m_refUserApi.UserId, "userprop", 1, 0, 1);
            cGroup = m_refUserApi.GetUserGroupById(1);
            sync_data = m_refUserApi.GetADStatus();

            try
            {
                domain_data = m_refUserApi.GetDomains(1, 0);
            }
            catch
            {
                domain_data = null;
            }

            EditToolBar(); //POPULATE TOOL BAR
            //VERSION
            versionNumber.InnerHtml = m_refMsg.GetMessage("version") + "&nbsp;" + m_refSiteApi.Version + "&nbsp;" + m_refSiteApi.ServicePack;
            //BUILD NUMBER
            buildNumber.InnerHtml = "<i>(" + m_refMsg.GetMessage("build") + m_refSiteApi.BuildNumber + ")</i>";

            if ((sync_data.SyncUsers) || (sync_data.SyncGroups) || (sync_data.SyncRelationships) || (sync_data.DeSyncUsers) || (sync_data.DeSyncGroups))
            {
                if (setting_data.ADAuthentication == 1)
                {
                    ltr_status.Text = "<a href=\"adreports.aspx?action=ViewAllReportTypes\">" + m_refMsg.GetMessage("ad enabled not configured") + "</a>";
                }
                else
                {
                    ltr_status.Text = "<a href=\"adreports.aspx?action=ViewAllReportTypes\">" + m_refMsg.GetMessage("ad disabled not configured") + "</a>";
                }
            }
            //Ektron.Cms.Sync doesn't have "visible"
            //else
            //{
            //    Ektron.Cms.Sync.visible = false;
            //}

            if (setting_data.IsAdInstalled)
            {
                installed.InnerHtml = m_refMsg.GetMessage("active directory installed");
            }
            else
            {
                installed.InnerHtml = m_refMsg.GetMessage("active directory not installed");
            }

            if (setting_data.ADAuthentication == 1)
            {
                EnableADAuth.Checked = true;
                adselectedstate = "";
                //OrgUnitText.Disabled = True
                OrgText.Disabled = true;
                ServerText.Disabled = true;
                drp_LDAPtype.Enabled = false;
                PortText.Disabled = true;
                LDAPDomainText.Disabled = true;
                txtLDAPAttribute.Enabled = false;
                LDAP_SSL.Disabled = true;
                admingroupdomain.Disabled = false;
                admingroupname.Disabled = false;
                drpAutoAddType.Enabled = true;
            }
            else if (setting_data.ADAuthentication == 0)
            {
                DisableAD.Checked = true;
                adselectedstate = "disabled";
                //OrgUnitText.Disabled = True
                OrgText.Disabled = true;
                ServerText.Disabled = true;
                drp_LDAPtype.Enabled = false;
                PortText.Disabled = true;
                LDAPDomainText.Disabled = true;
                txtLDAPAttribute.Enabled = false;
                LDAP_SSL.Disabled = true;
                admingroupdomain.Disabled = true;
                admingroupname.Disabled = true;
            }
            else
            {
                EnableLDAP.Checked = true;
                adselectedstate = "disabled";
                //OrgUnitText.Disabled = False
                OrgText.Disabled = false;
                ServerText.Disabled = false;
                drp_LDAPtype.Enabled = true;
                PortText.Disabled = false;
                LDAPDomainText.Disabled = false;
                txtLDAPAttribute.Enabled = true;
                LDAP_SSL.Disabled = false;
                admingroupdomain.Disabled = true;
                admingroupname.Disabled = true;
            }

            lgd_autoAddType.InnerHtml = m_refMsg.GetMessage("lbl auto add header");
            autoAddTypeProperty.InnerHtml = m_refMsg.GetMessage("lbl auto add user type");
            drpAutoAddType.Items.Add(new ListItem(m_refMsg.GetMessage("lbl author"), "0"));
            drpAutoAddType.Items.Add(new ListItem(m_refMsg.GetMessage("lbl member"), "1"));
            drpAutoAddType.SelectedIndex = setting_data.ADAutoUserAddType.GetHashCode();

            if (setting_data.ADIntegration)
            {
                EnableADInt.Checked = true;
            }
            if (!(setting_data.ADAuthentication == 1))
            {
                EnableADInt.Disabled = true;
            }
            if (setting_data.ADAutoUserAdd)
            {
                EnableAutoUser.Checked = true;
            }
            if (!(setting_data.ADAuthentication == 1))
            {
                EnableAutoUser.Disabled = true;
            }
            //EnableAutoUserToGroup
            if (setting_data.ADAutoUserToGroup)
            {
                EnableAutoUserToGroup.Checked = true;
            }
            if (!(setting_data.ADAuthentication == 1))
            {
                EnableAutoUserToGroup.Disabled = true;
            }

            userProperty.InnerHtml = m_refMsg.GetMessage("user property mapping");
            cmsProperty.InnerHtml = m_refMsg.GetMessage("cms property value");
            activeDirectoryProperty.InnerHtml = m_refMsg.GetMessage("active directory property value");
            userpropcount.Value = mapping_data.Length.ToString();

            int i;
            System.Text.StringBuilder result = new System.Text.StringBuilder();
            if (!(mapping_data == null))
            {
                for (i = 0; i <= mapping_data.Length - 1; i++)
                {
                    result.Append("<tr>");
                    result.Append("<td class=\"label\">" + GetResourseText(mapping_data[i].CmsName) + ":</td>");
                    result.Append("<td>");
                    result.Append("<input type=\"hidden\" maxlength=\"50\" size=\"50\" name=\"userpropname" + (i + 1) + "\"  id=\"userpropname" + (i + 1) + "\" value=\"" + mapping_data[i].CmsName + "\">");
                    result.Append("<input type=\"text\" maxlength=\"50\" size=\"25\" " + adselectedstate + " name=\"userpropvalue" + (i + 1) + "\" id=\"userpropvalue" + (i + 1) + "\" value=\"" + mapping_data[i].AdName + "\">");
                    result.Append("</td>");
                    result.Append("</tr>");
                }
                mapping_list.Text = result.ToString();
                result = null;
            }
            adminGroupMap.InnerHtml = m_refMsg.GetMessage("cms admin group map");
            adGroupName.InnerHtml = m_refMsg.GetMessage("AD Group Name");
            adDomain.InnerHtml = m_refMsg.GetMessage("AD Domain");
            admingroupname.Value = cGroup.GroupName;
            admingroupdomain.Value = cGroup.GroupDomain;
            drp_LDAPtype.Items.Add(new ListItem(m_refMsg.GetMessage("LDAP AD"), "AD"));
            drp_LDAPtype.Items.Add(new ListItem(m_refMsg.GetMessage("LDAP NO"), "NO"));
            drp_LDAPtype.Items.Add(new ListItem(m_refMsg.GetMessage("LDAP SU"), "SU"));
            drp_LDAPtype.Items.Add(new ListItem(m_refMsg.GetMessage("LDAP OT"), "OT"));
            drp_LDAPtype.Attributes.Add("onchange", "javascript:CheckLDAP(\'\', true);");
            if (setting_data.ADAuthentication == 2)
            {
                if (setting_data.ADDomainName.IndexOf("&lt;/p&gt;") + 1 > 0) //defect 17813 - SMK
                {
                    setting_data.ADDomainName = setting_data.ADDomainName.Replace("&lt;", "<");
                    setting_data.ADDomainName = setting_data.ADDomainName.Replace("&gt;", ">");
                    setting_data.ADDomainName = setting_data.ADDomainName.Replace("&quot;", "\"");
                    setting_data.ADDomainName = setting_data.ADDomainName.Replace("&#39;", "\'");
                }
                LDAPSettingsData ldapsettings;
                ldapsettings = Ektron.Cms.Common.EkFunctions.GetLDAPSettings(setting_data.ADDomainName);

                /* From VB source
                arrDomain = Split(setting_data.ADDomainName, "</server>")
                arrServer = Split(arrDomain(0), "</p>")
                */

                string tempDomainName = setting_data.ADDomainName;
                tempDomainName = tempDomainName.Replace("</server>", "|").Replace("</p>", "^");
                arrDomain = tempDomainName.Split("|".ToCharArray());
                arrServer = arrDomain[0].ToString().Split("^".ToCharArray());

                ServerText.Value = ldapsettings.Server;
                PortText.Value = ldapsettings.Port.ToString();
                LDAPjs.Text += "<script language=\"javascript\" type=\"text/javascript\">" + Environment.NewLine;

                drp_LDAPtype.SelectedIndex = ldapsettings.ServerType.GetHashCode();
                LDAPjs.Text += "     CheckLDAP(\'" + drp_LDAPtype.Items[drp_LDAPtype.SelectedIndex].Value + "\', false);" + Environment.NewLine;
                LDAP_SSL.Checked = ldapsettings.EncryptionType == Ektron.Cms.Common.EkEnumeration.LDAPEncryptionType.SSL;
                txtLDAPAttribute.Text = ldapsettings.Attribute;
                if ((arrServer.Length - 1) > 1)
                {
                    // arrLDAPDomain = Split(arrServer(2), ",") VB Source
                    arrLDAPDomain = arrServer[2].Split(',');
                    for (arrCount = 0; arrCount <= (arrLDAPDomain.Length - 1); arrCount++)
                    {
                        arrLDAPDomainElement = arrLDAPDomain.GetValue(arrCount).ToString().Split('=');
                        if (arrLDAPDomainElement[0] == "dc")
                        {
                            if (!(strLDAPDomain == ""))
                            {
                                strLDAPDomain += ".";
                            }
                            strLDAPDomain += arrLDAPDomainElement[1];
                        }
                    }
                    LDAPDomainText.Value = strLDAPDomain;
                }

                arrOrg2 = arrDomain[1].Split(new string[] {"</>"}, StringSplitOptions.None);
                for (arrCount2 = 0; arrCount2 <= (arrOrg2.Length - 1); arrCount2++)
                {
                    //Response.Write(arrOrg2(arrCount2) & "<br/>")
                    if (!(arrOrg2.GetValue(arrCount2).ToString() == ""))
                    {
                        arrOrg = arrOrg2.GetValue(arrCount2).ToString().Split(',');
                        for (arrCount = 0; arrCount <= (arrOrg.Length - 1); arrCount++)
                        {
                            if (!(arrOrg.GetValue(arrCount).ToString() == ""))
                            {
                                //arrItem = Strings.Split(arrOrg(arrCount), "=", -1, 0);
                                arrItem = arrOrg.GetValue(arrCount).ToString().Split('=');
                                if ((arrItem[0].Trim() == "o") && arrCount2 == (arrOrg2.Length - 1))
                                {
                                    OrgText.Value = arrItem.GetValue(1).ToString();
                                    //ElseIf (arrItem(0) = "ou" Or arrItem(0) = " ou") Then
                                    //    If (Not first) Then
                                    //        OrgUnitText.Value &= ","
                                    //    End If
                                    //    OrgUnitText.Value &= "ou=" & arrItem(1)
                                    //    isUnit = True
                                    //    first = False
                                }
                                else
                                {
                                    if (! first)
                                    {
                                        OrgUnitText.Value += ",";
                                    }
                                    OrgUnitText.Value += arrOrg.GetValue(arrCount);
                                    isUnit = true;
                                    first = false;
                                }
                            }
                        }
                        if (isUnit)
                        {
                            OrgUnitText.Value += "</>";
                            isUnit = false;
                            first = true;
                        }
                    }
                }
            }
            if (domain_data == null)
            {
                searchLink.InnerHtml = "<a href=\"#\" OnClick=\"javascript:alert(\'" + m_refMsg.GetMessage("javascript: alert cannot search no domains") + "\\n" + m_refMsg.GetMessage("generic check ad config msg") + "\'); return false;\">" + m_refMsg.GetMessage("generic Search") + "</a>";
            }
            else if (domain_data.Length == 0)
            {
                searchLink.InnerHtml = "<a href=\"#\" OnClick=\"javascript:alert(\'" + m_refMsg.GetMessage("javascript: alert cannot search no domains") + "\\n" + m_refMsg.GetMessage("generic check ad config msg") + "\'); return false;\">" + m_refMsg.GetMessage("generic Search") + "</a>";
            }
            else
            {
                searchLink.InnerHtml = "<a href=\"#\" OnClick=\"javascript:DoSearch();\">" + m_refMsg.GetMessage("generic Search") + "</a>";
            }
            domain.InnerHtml = m_refMsg.GetMessage("domain title") + ":";
            result = new System.Text.StringBuilder();
            result.Append("&nbsp;");

            if (domain_data == null && !m_refUserApi.RequestInformationRef.ADAdvancedConfig)
            {
                string selected = "";
                result.Append("<select " + adselectedstate + " name=\"domainname\" id=\"domainname\">");
                if (setting_data.ADDomainName == "")
                {
                    selected = " selected";
                }
                // Keep the "All Domains" drop down for continuity
                result.Append("<option value=\"\" " + selected + ">" + m_refMsg.GetMessage("all domain select caption") + "</option>");
                result.Append("</select>");
            }
            else if ((domain_data == null &&  m_refUserApi.RequestInformationRef.ADAdvancedConfig)
                    || domain_data.Length == 0)
            {
                result.Append("<font color=\"red\"><strong>" + m_refMsg.GetMessage("generic no domains found") + " " + m_refMsg.GetMessage("generic check ad config msg") + "</strong></font>");
            }
            else
            {
                if (m_refUserApi.RequestInformationRef.ADAdvancedConfig)
                {
                    for (i = 0; i <= domain_data.Length - 1; i++)
                    {
                        if (i > 0)
                            result.Append("&nbsp;");
                        result.Append(domain_data[i].Name).Append("<br/>");
                    }
                }
                else
                {
                    string selected = "";
                    result.Append("<select " + adselectedstate + " name=\"domainname\" id=\"domainname\">");
                    if (setting_data.ADDomainName == "")
                    {
                        selected = " selected";
                    }

                    result.Append("<option value=\"\" " + selected + ">" + m_refMsg.GetMessage("all domain select caption") + "</option>");
                    for (i = 0; i <= domain_data.Length - 1; i++)
                    {
                        if (domain_data[i].Name == setting_data.ADDomainName)
                        {
                            selected = " selected";
                        }
                        else
                        {
                            selected = "";
                        }
                        result.Append("<option value=\"" + domain_data[i].Name + "\"" + selected + ">" + domain_data[i].Name + "</option>");
                    }
                    result.Append("</select>");
                }
            }
            domainDropdown.InnerHtml = result.ToString();
            return false;
    }