Exemple #1
0
        /// <summary>
        /// This Constructor is meant to be used for SSIS packages.
        /// As the path for input/output files had to be built dynamically
        /// </summary>
        /// <remarks></remarks>
        public CentralEngine(string strUserName, string strAppName, string machineName)
        {
            string strUserID;
            int    index;

            //Strip User Name
            index = strUserName.LastIndexOf(@"\");
            if (index > 0)
            {
                index = index + 1;
            }
            strUserID = strUserName.Substring(index);

            AppName = strAppName;

            if (GHCActiveDirectory.IsMemberOf(machineName, GHCActiveDirectory.PrincipalType.Machine, "Dev_App_Environment"))
            {
                AppPath = "\\\\asnas\\SourceCode\\" + strUserID + "\\Integration\\Operations\\SSIS\\" + AppName;
            }
            else
            {
                AppPath = "\\\\asnas\\Central\\Bin\\" + AppName;
            }

            // check if input path exists, if it doesn't then try to create it
            if (!Directory.Exists(this.AppPath + "\\Files\\"))
            {
                Directory.CreateDirectory(this.AppPath + "\\Files\\");
            }
            InputPath  = this.AppPath + "\\Files\\";
            OutputPath = InputPath;
        }
Exemple #2
0
        static void IsMemberOfTest()
        {
            string principalName = "jschmidt";
            string groupName     = "DB_ClarityProd_Read";

            if (GHCActiveDirectory.IsMemberOf("jschmidt", GHCActiveDirectory.PrincipalType.User, "DB_ClarityProd_Read"))
            {
                Console.WriteLine("User '" + principalName + "' is a member of '" + groupName + "'");
            }
            else
            {
                Console.WriteLine("User '" + principalName + "' is NOT a member of '" + groupName + "'");
            }
        }
Exemple #3
0
        static void FindContext()
        {
            string principalName = Environment.MachineName;
            //string principalName = "ASDEVP";
            string groupName = "Dev_App_Environment";

            if (GHCActiveDirectory.IsMemberOf(principalName, GHCActiveDirectory.PrincipalType.Machine, groupName))
            {
                Console.WriteLine("We are in a development environment");
            }
            else
            {
                Console.WriteLine("We are in a production environment");
            }
        }
        // SQL Server Connection String
        // "PERSIST SECURITY INFO=FALSE;INTEGRATED SECURITY=SSPI;DATA SOURCE=ASCLARITYDEV;INITIAL CATALOG=CLARITY;CONNECT TIMEOUT=6000"

        // OLE DB Connection String
        // "Provider=SQLOLEDB;Server=ASCLARITYDEV;Database=CLARITY;Integrated Security=SSPI"

        // ODBC Connection String
        // "Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;"
        // "Driver={SQL Server Native Client 11.0};Server=ASCLARITYDEV;Database=CLARITY;Trusted_Connection=True;"

        #endregion

        /// <summary>
        /// Gets the connection string for the database and provider.  The environment is inferred based on the machin name.
        /// If the machine is identified in Active Directory as belonging to the DEV_GROUP_NAME, then the connection string
        /// will be for DEV.  All other machines will retrieve the production connection string unless overridden.
        /// </summary>
        /// <param name="database">string</param>
        /// <param name="dataProviderType">DataProviderType</param>
        /// <returns>string</returns>
        public static string GetConnectionString(string database, DataProviderType dataProviderType)
        {
            string machineName      = System.Environment.MachineName;
            string connectionString = "";

            if (GHCActiveDirectory.IsMemberOf(machineName, GHCActiveDirectory.PrincipalType.Machine, DEV_GROUP_NAME))
            {
                connectionString = GetConnectionString(database, dataProviderType, DBEnvironment.DEV);
            }
            else
            {
                connectionString = GetConnectionString(database, dataProviderType, DBEnvironment.PROD);
            }

            return(connectionString);
        }
        /// <summary>
        /// Retrieves the actual string from the repository.  This could be Active Directory,
        /// app.config, registry, or something else entirely.  The current implementation is
        /// using active directory through the GHCSecurity object, retrieving the connection
        /// string from the description of an AD account created specifically to store the
        /// connection strings
        /// </summary>
        /// <param name="database">string</param>
        /// <param name="environment">Environment</param>
        /// <returns>string</returns>
        private static string GetStringFromRepository(string database, DataProviderType dataProviderType, DBEnvironment environment)
        {
            string connectionString = "";

            // connection strings are stored in active directory as the description for a user.
            // the username is 'database + environment', so CLARITYDEV would return the dev
            // connection string.
            connectionString = GHCActiveDirectory.GetUserDescription(database + environment);

            #region "ResourceManager Repository"
            //System.Resources.ResourceManager rm = GHCDataAccess.Properties.Resources.ResourceManager;
            //connectionString = rm.GetString(database + environment);

            //if(connectionString == null)
            //{
            //    throw new System.ArgumentOutOfRangeException("ConnectionName", "Invalid connection name.  The database and environment requested does not exist as a resource. (" + database + " :: " + environment + ")");
            //}
            #endregion "ResourceManager Repository"

            return(connectionString);
        }
Exemple #6
0
 static void GetUserDetailsTest()
 {
     Console.WriteLine(GHCActiveDirectory.GetUserDescription("CLARITYPROD"));
 }