} //end of method public bool isMemberOfADGroup(string UserName, string Password, string GroupName) { bool userFound = false; string strUserName = ""; try { switch (domain) { case DomainNames.ENT: strUserName = "******" + UserName.Trim(); break; case DomainNames.R7BC_WEB: strUserName = "******" + UserName.Trim(); break; case DomainNames.WebApps: strUserName = UserName.Trim(); break; } DirectoryEntry de = new DirectoryEntry(strDomainPath, strUserName, Password.Trim(), AuthenticationTypes.Secure); DirectorySearcher ds = new DirectorySearcher(de); ds.ReferralChasing = ReferralChasingOption.All; ds.SearchScope = SearchScope.Subtree; ds.Filter = "(&(objectClass=user)(objectClass=person)(sAMAccountName=" + UserName.Trim() + "))"; ds.PropertiesToLoad.Add("sAMAccountName"); //1. ENT ds.PropertiesToLoad.Add("MemberOf"); //2. Membership SearchResult myUsers = ds.FindOne(); //User is found in the Active Directory if (myUsers != null && myUsers.Properties.Values.Count > 0) { int NumberOfGroups = myUsers.Properties["memberOf"].Count - 1; string tempString = ""; while (NumberOfGroups >= 0) { tempString = myUsers.Properties["MemberOf"][NumberOfGroups].ToString(); tempString = tempString.Substring(0, tempString.IndexOf(",", 0)).Replace("CN=", ""); //Above we set tempString to the first index of "," starting from the zeroth element of itself. //tempString = tempString.Replace("CN=", "") ; //Above, we remove the "CN=" from the beginning of the string // tempString = tempString.ToLower(); //'Lets make all letters lowercase // tempString = tempString.Trim(); //Finnally, we trim any blank characters from the edges if (GroupName.ToLower().Trim() == tempString.Trim().ToLower()) { userFound = true; break; } //If we have a match, the return is true username is a member of grouptoCheck NumberOfGroups = NumberOfGroups - 1; } } } catch (Exception exp) { EventLog.AddWebErrors("GSA.R7BD.Utility", "ADAuthentication", "isMemberOfADGroup", "User - " + UserName.Trim() + " , Error - " + exp.Message); } return(userFound); } //end of method
public static void InsertAuditData(string external_user_id, string system_of_record, string changing_table, string changing_column, string record_pk, string created_by, string old_value, string new_value) { string strSQL = ""; try { using (OracleConnection conBdrpt = new OracleConnection(DataAccess.ConnStrBDFApps())) { if (conBdrpt.State != ConnectionState.Open) { conBdrpt.Open(); } strSQL = ("insert into bdfapps.sys_data_audit columns(sys_data_audit_id, external_user_id, system_of_record, changing_table, "); strSQL = strSQL + ("changing_column, record_pk, created_by, created_date, old_value, new_value) values (bdfapps.sys_data_audit_seq.NEXTVAL, "); strSQL = strSQL + ("'" + external_user_id + "', '" + system_of_record + "', '" + changing_table + "', '" + changing_column + "', "); strSQL = strSQL + ("'" + record_pk + "', '" + created_by + "', sysdate, '" + old_value + "', '" + new_value + "') "); OracleCommand cmd = new OracleCommand(strSQL, conBdrpt); cmd.ExecuteNonQuery(); } } catch (Exception exp) { EventLog.AddWebErrors("Utility", "Audit.cs", "InsertAuditData", exp.Message); } }
public static string CopyAndReturnTempImg(string imageId) { string strImageFile = string.Empty; string fileExtension = string.Empty; strImageFile = imageId.Trim(); fileExtension = System.IO.Path.GetExtension(strImageFile).Substring(1); string strNewFile = GetNewFileName(getDrivePathByLetter("FILELOG:"), fileExtension); if (!string.IsNullOrEmpty(strImageFile)) { try { System.IO.File.Copy(strImageFile, getDrivePathByLetter("FILELOG:") + strNewFile, true); return(strNewFile); } catch (Exception exp) { EventLog.AddWebErrors("GSA.R7BD.Utility", "Utilities", "CopyAndReturnImgPath", exp.Message.ToString()); return(strNewFile); } } else { return(string.Empty); } }
//2/09/2005 - Madan - web_users table in VITAP.world //Input parameter UserName = First Name Initial, LastName public static string IsValidWebUser(string UserName, string Password, System.Data.OracleClient.OracleConnection App_Connection) { string Message = ""; try { System.Data.OracleClient.OracleCommand CmdLotusMail = new System.Data.OracleClient.OracleCommand(); CmdLotusMail.CommandText = "SELECT password from web_users WHERE (externalservice ='T' or app_dfas_fl ='T') and upper(login_id) = '" + Utilities.SqlEncode(UserName.ToUpper().Trim()) + "'"; CmdLotusMail.Connection = App_Connection; //ConnLotusMail; if (App_Connection.State != System.Data.ConnectionState.Open) { CmdLotusMail.Connection.Open(); } System.Data.OracleClient.OracleDataReader myReader = CmdLotusMail.ExecuteReader(); if (myReader.Read()) { Message = myReader["password"].ToString().Trim(); } myReader.Close(); CmdLotusMail.Connection.Close(); } catch (System.Exception ex) { // if exception occurs, make an entry in the server event log EventLog.AddWebErrors("GSA.R7BD.Utility", "Security", "IsLutusNotesUser", ex.Message); } return(Message.Trim()); } //end of this method
}//end of method public static string AuthenticateLotusNotesUser(string firstName, string lastName, System.Data.OracleClient.OracleConnection App_Connection) { string Message = ""; string UserName1 = firstName.Trim().ToUpper() + " " + lastName.Trim().ToUpper(); string UserName2 = lastName.Trim().ToUpper() + ", " + firstName.Trim().ToUpper(); try { System.Data.OracleClient.OracleCommand CmdLotusMail = new System.Data.OracleClient.OracleCommand(); CmdLotusMail.CommandText = "SELECT Notesname from maildir WHERE Notesname = '" + Utilities.SqlEncode(UserName1.ToUpper().Trim()) + "' or upper(Name) ='" + Utilities.SqlEncode(UserName2) + "'"; CmdLotusMail.Connection = App_Connection;// ConnLotusMail; if (App_Connection.State != System.Data.ConnectionState.Open) { CmdLotusMail.Connection.Open(); } System.Data.OracleClient.OracleDataReader NotesReader = CmdLotusMail.ExecuteReader(); if (NotesReader.Read()) { Message = NotesReader["Notesname"].ToString().Trim(); } NotesReader.Close(); CmdLotusMail.Connection.Close(); } catch (System.Exception ex) { // if exception occurs, make an entry in the server event log EventLog.AddWebErrors("GSA.R7BD.Utility", "Security", "IsLutusNotesUser", ex.Message); } return(Message); }//end of method
} //end of method // Added from decompiled dll public string getDistinguishedName(string UserName, string Password) { string username = ""; string str2 = ""; try { switch (this.domain) { case DomainNames.ENT: username = @"ENT\" + UserName.Trim(); break; case DomainNames.R7BC_WEB: username = @"R7BC_WEB.INT\" + UserName.Trim(); break; case DomainNames.WebApps: username = UserName.Trim(); break; //case DomainNames.ENT2008: // username = UserName.Trim(); // break; } DirectoryEntry searchRoot = new DirectoryEntry(this.strDomainPath, username, Password, AuthenticationTypes.Secure); DirectorySearcher searcher = new DirectorySearcher(searchRoot) { ReferralChasing = ReferralChasingOption.All, SearchScope = SearchScope.Subtree, Filter = "(&(objectClass=user)(objectClass=person)(sAMAccountName=" + UserName + "))" }; searcher.PropertiesToLoad.Add("sAMAccountName"); searcher.PropertiesToLoad.Add("mail"); searcher.PropertiesToLoad.Add("name"); searcher.PropertiesToLoad.Add("distinguishedName"); Hashtable hashtable = new Hashtable(); SearchResult result = searcher.FindOne(); if ((result != null) && (result.Properties.Values.Count > 0)) { ResultPropertyValueCollection values = result.Properties["distinguishedName"]; foreach (object obj2 in values) { hashtable.Add("distinguishedName", obj2.ToString()); } if (hashtable.ContainsKey("distinguishedName")) { str2 = hashtable["distinguishedName"].ToString().Trim().ToUpper(); } } } catch (Exception exception) { EventLog.AddWebErrors("GSA.R7BD.Utility", "ADAuthentication", "getDistinguishedName", "User - " + UserName.Trim() + " , Error - " + exception.Message); } return(str2.Trim()); }
}//end of method public static string SetImagePath(string imageId) { string strImageIPath = string.Empty; string strImageVPath = string.Empty; string uncPath = string.Empty; try { strImageIPath = getDrivePathByLetter("IMAGEIDRIVEMAPPINGDIR:"); strImageVPath = getDrivePathByLetter("IMAGEVDRIVEMAPPINGDIR:"); if (imageId.LastIndexOf(":") > 0) { string firstChar = imageId.Substring(0, 1).ToUpper(); switch (firstChar) { case "I": imageId = strImageIPath + imageId.Substring(imageId.LastIndexOf(":\\") + 2).Trim(); break; case "V": imageId = strImageVPath + imageId.Substring(imageId.LastIndexOf(":\\") + 2).Trim(); break; } } if (imageId.Substring(0, 2) == "\\\\" && !imageId.Substring(0, 12).Equals("\\\\e07bds-san", StringComparison.CurrentCultureIgnoreCase)) { //code for IP if (imageId.IndexOf("\\images", StringComparison.CurrentCultureIgnoreCase) > 0) { imageId = imageId.ToLower().Replace(imageId.ToLower().Substring(0, imageId.ToLower().IndexOf("\\images") + 7), strImageIPath); } if (imageId.IndexOf("\\vitap", StringComparison.CurrentCultureIgnoreCase) > 0) { imageId = imageId.ToLower().Replace(imageId.ToLower().Substring(0, imageId.ToLower().IndexOf("\\vitap") + 6), strImageVPath); } } imageId = imageId.ToLower().Replace("\\\\e07bds-san\\images\\", strImageIPath.ToLower()); imageId = imageId.ToLower().Replace("\\\\e07bds-san.r7bc.int\\images\\", strImageIPath.ToLower()); imageId = imageId.ToLower().Replace("\\\\e07bds-san\\vitap\\", strImageVPath.ToLower()); imageId = imageId.ToLower().Replace("\\\\e07bds-san.r7bc.int\\vitap\\", strImageVPath.ToLower()); return(imageId); } catch (Exception exp) { EventLog.AddWebErrors("GSA.R7BD.Utility", "Utilities", "SetImagePath", exp.Message.ToString()); return(imageId); } }
} //end of method public string[] getGroupMemberships(string UserName, string Password) { string[] userMemberships = null; string strUserName = ""; try { switch (domain) { case DomainNames.ENT: strUserName = "******" + UserName.Trim(); break; case DomainNames.R7BC_WEB: strUserName = "******" + UserName.Trim(); break; case DomainNames.WebApps: strUserName = UserName.Trim(); break; } DirectoryEntry de = new DirectoryEntry(strDomainPath, strUserName, Password.Trim(), AuthenticationTypes.Secure); DirectorySearcher ds = new DirectorySearcher(de); ds.ReferralChasing = ReferralChasingOption.All; ds.SearchScope = SearchScope.Subtree; ds.Filter = "(&(objectClass=user)(objectClass=person)(sAMAccountName=" + UserName.Trim() + "))"; ds.PropertiesToLoad.Add("MemberOf"); //1. Membership SearchResult myUsers = ds.FindOne(); //User is found in the Active Directory if (myUsers != null && myUsers.Properties.Values.Count > 0) { int NumberOfGroups = myUsers.Properties["memberOf"].Count; userMemberships = new string[NumberOfGroups]; string tempString = ""; for (int i = 0; i < NumberOfGroups; i++) { tempString = myUsers.Properties["MemberOf"][i].ToString(); tempString = tempString.Substring(0, tempString.IndexOf(",", 0)).Replace("CN=", ""); userMemberships[i] = tempString.Trim().ToUpper(); } } } catch (Exception exp) { EventLog.AddWebErrors("GSA.R7BD.Utility", "ADAuthentication", "getGroupMemberships", "User - " + UserName.Trim() + " , Error - " + exp.Message); } return(userMemberships); } //end of method
} //end of this method /// <summary> /// This method return the drive path /// </summary> /// <param name="driveLetter"></param> /// <param name="configFile"></param> /// <returns></returns> public static string getDrivePath(string driveLetter, string configFile) { string drivepath = ""; try { if (!driveLetter.Trim().EndsWith(":")) { driveLetter = driveLetter.Trim() + ":"; } //string FilePath = System.Environment.GetEnvironmentVariable("FINANCECONFIG"); //Read from Env variable //if (FilePath == null) { FilePath = "C:\\Finance\\"; } string FilePath = ConfigurationManager.AppSettings["FINANCECONFIG"]; if (FilePath == null) { FilePath = "D:\\financeconfig\\"; } if (!FilePath.EndsWith("\\")) { FilePath += "\\"; } FilePath += configFile.Trim(); DSPATH myDataSet = new DSPATH(); myDataSet.ReadXml(FilePath.Trim()); if (myDataSet.NetworkMappings.Rows.Count > 0) { DataRow[] rowsFound = myDataSet.NetworkMappings.Select("DriveLetter ='" + driveLetter.Trim().ToUpper() + "' OR DriveLetter ='" + driveLetter.Trim().ToLower() + "'"); if (rowsFound.Length > 0) { drivepath = rowsFound[0]["DrivePath"].ToString().Trim(); } else { drivepath = "ERROR: Path not found for '" + driveLetter + "'"; EventLog.AddWebErrors("GSA.R7BD.Utility", "Utilities", "getDrivePath", drivepath); } } } catch (Exception exp) { drivepath = "ERROR:" + exp.Message; EventLog.AddWebErrors("GGSA.R7BD.Utility", "Utilities", "getDrivePath", exp.Message); } return(drivepath); }//end of method
public static string GetUrl(string driveLetter, string appName) { string drivepath = ""; try { if (!driveLetter.Trim().EndsWith(":")) { driveLetter = driveLetter.Trim() + ":"; } string configFilePath = ConfigurationManager.AppSettings["FINANCECONFIG"].ToString(); if (configFilePath == null) { configFilePath = "D:\\financeconfig\\"; } if (!configFilePath.EndsWith("\\")) { configFilePath += "\\"; } configFilePath = configFilePath.Trim() + "urls.xml"; DSPATH myDataSet = new DSPATH(); myDataSet.ReadXml(configFilePath.Trim()); if (myDataSet.NetworkMappings.Rows.Count > 0) { DataRow[] rowsFound = myDataSet.NetworkMappings.Select("DriveLetter ='" + driveLetter.Trim().ToUpper() + "' OR DriveLetter ='" + driveLetter.Trim().ToLower() + "'"); if (rowsFound.Length > 0) { drivepath = rowsFound[0]["DrivePath"].ToString().Trim(); } else { EventLog.AddWebErrors("GSA.R7BD.Utility", "Utilities", "GetUrl", " AppName:" + appName + " DriveLetter:" + driveLetter); } } } catch (Exception exp) { EventLog.AddWebErrors("GSA.R7BD.Utility", "Utilities", "GetUrl", exp.Message + " AppName:" + appName + " DriveLetter:" + driveLetter); } return(drivepath); }
public static DataSet AuditColumns(string strAppName, string strTable, string strAudInd) { DataSet ds = new DataSet(); OracleDataAdapter daColumns = new OracleDataAdapter(); try { using (OracleConnection conBdrpt = new OracleConnection(DataAccess.ConnStrBDFApps())) { string sqlSelect = "select * from bdfapps.sys_audit_column where system_of_record = '" + strAppName + "' and LOWER(changing_table) = lower('" + strTable + "') and audit_ind = '" + strAudInd + "'"; daColumns.SelectCommand = new OracleCommand(sqlSelect, conBdrpt); daColumns.Fill(ds); } } catch (Exception exp) { EventLog.AddWebErrors("Utility", "Audit.cs", "AuditColumns", exp.Message); } return(ds); }
} //end of this method // //This routine will return a unique file name for the given extension in the folder passed public static string GetNewFileName(string Path, string FileExt) { string RandomNo; string NewFileName = "OK Man"; string NewExcelName; if (!FileExt.StartsWith(".")) { FileExt = "." + FileExt; } if (!Path.EndsWith("\\")) { Path = Path + "\\"; } try { // Initialize random-number generator. Random RandomNumber = new Random(); RandomNo = RandomNumber.Next(1, 9999).ToString(); // Generate random value between 1 and 9999. NewExcelName = RandomNo.Trim(); // RandomNo = RandomNumber.Next(1, 999).ToString(); // Generate random value between 1 and 999. NewFileName = "T" + NewExcelName + RandomNo.Trim() + FileExt; if (System.IO.File.Exists(Path + NewFileName)) //if this file exists create with a different name { RandomNo = RandomNumber.Next(1, 9999).ToString(); // Generate random value between 1 and 9999. NewExcelName = RandomNo.Trim(); // RandomNo = RandomNumber.Next(1, 999).ToString(); // Generate random value between 1 and 999. NewFileName = "I" + NewExcelName + RandomNo.Trim() + FileExt; } } catch (System.Exception exp) { Console.Write(exp.Message); EventLog.AddWebErrors("GSA.R7BD.Utility", "Utilities", "GetNewFileName", exp.Message); } return(NewFileName); } //end of this method
} // End of method public bool Authenticate(string UserName, string Password) { string userEmail = ""; string strUserName = ""; bool bResult = false; try { switch (domain) { case DomainNames.ENT: strUserName = "******" + UserName.Trim(); break; case DomainNames.R7BC_WEB: strUserName = "******" + UserName.Trim(); break; case DomainNames.WebApps: strUserName = UserName.Trim(); break; } DirectoryEntry de = new DirectoryEntry(strDomainPath, strUserName, Password.Trim(), AuthenticationTypes.Secure); DirectorySearcher ds = new DirectorySearcher(de); ds.ReferralChasing = ReferralChasingOption.All; ds.SearchScope = SearchScope.Subtree; ds.Filter = "(&(objectClass=user)(objectClass=person)(sAMAccountName=" + UserName.Trim() + "))"; ds.PropertiesToLoad.Add("sAMAccountName"); //1. ENT Account ds.PropertiesToLoad.Add("mail"); //2. EMail ds.PropertiesToLoad.Add("name"); //3. FullName Hashtable associateDetailsTable = new Hashtable(); ResultPropertyValueCollection resultCollection; SearchResult myUsers = ds.FindOne(); //User is found in the Active Directory if (myUsers != null && myUsers.Properties.Values.Count > 0) { //1. LoginID resultCollection = myUsers.Properties["sAMAccountName"]; foreach (object result in resultCollection) { associateDetailsTable.Add("LoginID", result.ToString()); } //2. Email resultCollection = myUsers.Properties["mail"]; foreach (object result in resultCollection) { associateDetailsTable.Add("Email", result.ToString()); } //3. Name resultCollection = myUsers.Properties["name"]; foreach (object result in resultCollection) { associateDetailsTable.Add("Name", result.ToString()); } userEmail = associateDetailsTable["Email"].ToString().Trim().ToLower() + "/" + associateDetailsTable["LoginID"].ToString().Trim().ToUpper() + "/" + associateDetailsTable["Name"].ToString().Trim().ToUpper(); // Now get the properties of the userID strEmail = associateDetailsTable["Email"].ToString().Trim().ToLower(); strName = associateDetailsTable["Name"].ToString().Trim().ToUpper(); strLoginID = associateDetailsTable["LoginID"].ToString().Trim().ToUpper(); bResult = true; } return(bResult); } catch (Exception exp) { EventLog.AddWebErrors("GSA.R7BD.Utility", "ADAuthentication", "Authenticate", "User - " + UserName.Trim() + " , Error - " + exp.Message); return(false); } } //end of method
// 03/07/2014 OCP 57515 RSNAP II: Jun Lee // Using Password Web Service, this routine returns the password for the database and user id passed protected internal static string GetPassword(string databaseName, string userID) { string dbPwd = ""; try { //srDBPassword.ServiceClient myService = new srDBPassword.ServiceClient(); srDBPassword.ServiceClient myService = new srDBPassword.ServiceClient(); dbPwd = myService.GetData(userID.Trim().ToLower(), databaseName.Trim().ToLower(), "a0c88e69-4489-4bac-b563-b2ab63526223"); myService.Close(); } catch (Exception exp) { dbPwd = "ERROR: " + exp.Message; EventLog.AddWebErrors("R7BD.Utility", "SharedPassword", "GetPassword", exp.Message + " " + userID.ToString() + "' in Database '" + databaseName.ToString() + "'"); } return(dbPwd.Trim()); //string passwordResult = ""; //StringBuilder connStr = new StringBuilder(); ////string Filepath = "d:\\components\\MSCTL32.tlb"; //StringBuilder FilePath = new StringBuilder(); //FilePath.Append(GSA.R7BD.Utility.Utilities.getDrivePathByLetter("MSCTL32")); //FilePath.Append("\\MSCTL32.tlb"); //try { // DataSet dsXML = new DataSet(); // if (System.IO.File.Exists(FilePath.ToString())) { //file exists) // try { // FileStream fsXML = new FileStream(FilePath.ToString(), FileMode.Open, FileAccess.Read); // dsXML.ReadXml(fsXML); // fsXML.Close(); // } // catch (Exception e) { // Console.Write(e.Message); // } // } // //Now lets read the value from dataset // if (dsXML.Tables["Stramboli"].Rows.Count > 0) { // System.Data.DataRow[] DR = dsXML.Tables["Stramboli"].Select("Request='" + XMLEncode(userID.Trim()) + "' and Visit='" + XMLEncode(databaseName.Trim()) + "'"); // if (DR.Length == 1) { // passwordResult = DR[0]["Hits"].ToString(); // passwordResult = XMLDecode(passwordResult); // passwordResult = Decode(passwordResult); // } // } // if (passwordResult == "") // { // EventLog.AddWebErrors("R7BD.Utility", "SharedPassword", "GetPassword", "Did not find password for userID '" + userID.ToString() + "' in Database '" + databaseName.ToString() + "'"); // } //} //catch (System.Exception e) { // Console.Write(e.Message); //} ////if password is empty in XML file then look at SANBox //if (passwordResult.Length == 0) { // System.Data.OleDb.OleDbDataReader passwordReader; // System.Data.OleDb.OleDbConnection passwordConnection = new System.Data.OleDb.OleDbConnection(); // System.Data.OleDb.OleDbCommand passwordCommand = new System.Data.OleDb.OleDbCommand(); // //Set connection / command information // //passwordConnection.ConnectionString = "Provider=VFPOLEDB.1;Data Source=M:\\finance;Mode=Share Deny None;Extended Properties='';User ID='';Password='';Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE"; // connStr.Append("Provider=VFPOLEDB.1;Data Source="); // connStr.Append(GSA.R7BD.Utility.Utilities.getDrivePathByLetter("PASSWORDSTABLE:")); // connStr.Append(";Mode=Share Deny None;Extended Properties='';User ID='';Password='';Mask Password=False;Cache Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE"); // passwordConnection.ConnectionString = connStr.ToString(); // passwordCommand.CommandText = "select password from passwords.dbf where upper(database) == '" + databaseName.Trim().ToUpper() + "' and upper(userid) == '" + userID.Trim().ToUpper() + "'"; // //Open and execute the command // try { // passwordCommand.Connection = passwordConnection; // passwordCommand.Connection.Open(); // passwordReader = passwordCommand.ExecuteReader(); // if (passwordReader.Read()) { // passwordResult = Decode(passwordReader.GetString(0)); // } // passwordCommand.Connection.Close(); // } // catch (System.Exception e) { // Console.Write(e.Message); // } //} //return passwordResult; } //end of this method