/// <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; }
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 + "'"); } }
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); }