// 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