Beispiel #1
0
        protected void btn2_Click(object sender, EventArgs e)
        {
            // Create ADM Active Directory Group
            Variables oVariable = new Variables(intEnvironment);

            if (intOrganization > 0)
            {
                DataSet dsOrganization = oOrganization.Get(intOrganization);
                if (dsOrganization.Tables[0].Rows.Count > 0)
                {
                    if (strOrganizationCode != "")
                    {
                        //int intCustodian = Int32.Parse(dsOrganization.Tables[0].Rows[0]["userid"].ToString());
                        int intCustodian = 0;
                        Int32.TryParse(oForecast.GetAnswer(intAnswer, "appowner"), out intCustodian);
                        if (intCustodian > 0)
                        {
                            // BEGIN PROCESSING
                            // Create DLG OUg_<mnemonic> groups
                            string strMnemonicGroupDLG = "OUg_" + strMnemonicCode;
                            if (oAD.SearchOU(strMnemonicGroupDLG) == null)
                            {
                                string strResultMnemonic = oAD.CreateOU(strMnemonicGroupDLG, "", "OU=OUc_Resources,");
                                if (strResultMnemonic == "")
                                {
                                    strResult += "The OU " + strMnemonicGroupDLG + " was successfully created in " + oVar.Name() + "<br/>";
                                }
                                else
                                {
                                    strError = "There was a problem creating the OU ~ " + strMnemonicGroupDLG + " in " + oVar.Name();
                                }
                            }
                            else
                            {
                                strResult += "The OU " + strMnemonicGroupDLG + " already exists in " + oVar.Name() + "<br/>";
                            }

                            if (strError == "")
                            {
                                // Assume the GG OU exists and continue creating
                                string   strGroupDescription = "Custodian: " + oUser.GetFullName(intCustodian) + " (" + oUser.GetName(intCustodian) + "), LOB-" + strOrganizationCode + ", MIS-" + strMnemonicCode + " " + strMnemonicName;
                                string[] strGroups           = oVariable.PNC_AD_Groups();

                                for (int ii = 0; ii < strGroups.Length && strError == ""; ii++)
                                {
                                    //string strNameDLG = "DLG_URA_" + strOrganizationCode + "_" + strMnemonicCode + "_" + strGroups[ii];
                                    string strNameDLG = "GSLfsaSP_" + strMnemonicCode + "_" + strGroups[ii];
                                    //string strNameGG = "GG_URA_" + strOrganizationCode + "_" + strMnemonicCode + "_" + strGroups[ii];
                                    string strNameGG = "GSGu_" + strMnemonicCode + "_" + strGroups[ii];

                                    if (strError == "")
                                    {
                                        if (oAD.Search(strNameDLG, false) == null)
                                        {
                                            string strResultDLG = oAD.CreateGroup(strNameDLG, strGroupDescription, "", "OU=" + strMnemonicGroupDLG + ",OU=OUc_Resources,", "DLG", "S");
                                            if (strResultDLG == "")
                                            {
                                                strResult += "The group " + strNameDLG + " was successfully created in " + oVar.Name() + "<br/>";
                                            }
                                            else
                                            {
                                                strError = "There was a problem creating the group ~ " + strNameDLG + " in " + oVar.Name();
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            strResult += "The group " + strNameDLG + " already exists in " + oVar.Name() + "<br/>";
                                        }
                                    }

                                    if (strError == "")
                                    {
                                        if (oAD.Search(strNameGG, false) == null)
                                        {
                                            string strResultGG = oAD.CreateGroup(strNameGG, strGroupDescription, "", "OU=OUg_Applications,OU=OUc_AccessGroups,", "GG", "S");
                                            if (strResultGG == "")
                                            {
                                                strResult += "The group " + strNameGG + " was successfully created in " + oVar.Name() + "<br/>";
                                            }
                                            else
                                            {
                                                strError = "There was a problem creating the group ~ " + strNameGG + " in " + oVar.Name();
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            strResult += "The group " + strNameGG + " already exists in " + oVar.Name() + "<br/>";
                                        }
                                    }

                                    if (strError == "")
                                    {
                                        // Add the GG to the DLG
                                        string strResultJoin = oAD.JoinGroup(strNameGG, strNameDLG, 0);
                                        if (strResultJoin == "")
                                        {
                                            strResult += "The global group " + strNameGG + " was successfully added to the domain local group " + strNameDLG + " in " + oVar.Name() + "<br/>";
                                        }
                                        else
                                        {
                                            strError = "There was a problem adding the global group ~ " + strNameGG + " to the domain local group " + strNameDLG + " in " + oVar.Name();
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            strError = "The organization is not configured for Active Directory Group naming (CUSTODIAN / USERID is blank) ~ (" + dsOrganization.Tables[0].Rows[0]["name"].ToString() + ")";
                        }
                    }
                    else
                    {
                        strError = "The organization is not configured for Active Directory Group naming (CODE is blank) ~ (" + dsOrganization.Tables[0].Rows[0]["name"].ToString() + ")";
                    }
                }
                else
                {
                    strError = "Invalid Organization";
                }
            }
            else
            {
                strError = "There is no organization specified for this project";
            }
            int intStep = 6;

            //oOnDemand.UpdateStepDoneServer(intServer, intStep, strResult, 0, false, true);

            Response.Write("<p><b>RESULT...</b></p><p>" + strResult + "</p>");
            Response.Write("<p><b>ERROR...</b></p><p>" + strError + "</p>");
        }