Esempio n. 1
0
        //---------------------------------------------------------------------------------------------------
        // Private Methods
        //---------------------------------------------------------------------------------------------------
        private void UpdatePathMsg()
        {
            string msg = "";

            if (!SAPLogonHandler.ValidateSAPGUIPath(this.tbSAPGUIPath.Text))
            {
                msg = Translatable.ValidationInfoNeg;
                msg = msg.Replace("%EXE_NAME%", SAPLogonHandler.SAPGUIShortCutEXE);
                this.tbPathValidInfo.Text = msg;
                return;
            }

            if (m_config != null)
            {
                if (m_config.AutoDetected)
                {
                    msg = Translatable.ValidationInfoAuto;
                    msg = msg.Replace("%EXE_NAME%", SAPLogonHandler.SAPGUIShortCutEXE);
                    this.tbPathValidInfo.Text = msg;
                    return;
                }
            }

            if (SAPLogonHandler.ValidateSAPGUIPath(this.tbSAPGUIPath.Text))
            {
                msg = Translatable.ValidationInfoPos;
                msg = msg.Replace("%EXE_NAME%", SAPLogonHandler.SAPGUIShortCutEXE);
                this.tbPathValidInfo.Text = msg;
                return;
            }
        }
Esempio n. 2
0
        public override bool SupportsCellAction(string strColumnName)
        {
            if (strColumnName == null)
            {
                Debug.Assert(false);
                return(false);
            }

            if (strColumnName != m_vColNames[0])
            {
                return(false);
            }

            return(SAPLogonHandler.ValidateSAPGUIPath(m_config.SAPGUIPath));
        }
Esempio n. 3
0
        public override void PerformCellAction(string strColumnName, PwEntry pe)
        {
            LogonColumn lc = GetSAPLogonData(strColumnName, pe);

            if (lc.IsValid())
            {
                lc.ExtendWithDefaults(m_config.DefaultLng, m_config.DefaultTx);

                ProtectedString pUser = DerefValue(PwDefs.UserNameField, pe);
                ProtectedString pPw   = DerefValue(PwDefs.PasswordField, pe);

                SAPLogonHandler.SAPGUIPath = m_config.SAPGUIPath;
                SAPLogonHandler.DoLogon(lc, pUser, pPw);
            }
        }
Esempio n. 4
0
        public override string GetCellData(string strColumnName, PwEntry pe)
        {
            if (strColumnName == null)
            {
                Debug.Assert(false);
                return(String.Empty);
            }

            if (strColumnName != m_vColNames[0])
            {
                return(String.Empty);
            }

            if (pe == null)
            {
                Debug.Assert(false);
                return(String.Empty);
            }


            if (!SAPLogonHandler.ValidateSAPGUIPath(m_config.SAPGUIPath))
            {
                return(Translatable.ColumnConfigFailure);
            }


            //detect SAP ID and SAP client
            string      strCellData = "";
            LogonColumn lc          = GetSAPLogonData(strColumnName, pe);

            if (lc.IsValid())
            {
                strCellData = FormattedCellData(lc);
            }
            else
            {
                if (lc.HasSAPID() || lc.HasSAPClient() || lc.HasSAPLanguage() || lc.HasSAPTransaction())
                {
                    strCellData = Translatable.ColumnInvalidData;
                }
                else
                {
                    strCellData = Translatable.ColumnNoneSAPData;
                }
            }

            return(strCellData);
        }
Esempio n. 5
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!(this.cbSAPID.Checked || this.cbClient.Checked || this.cbLanguage.Checked || this.cbTransaction.Checked))
            {
                MessageBox.Show(Translatable.ErrorMsgDisplayOption, KeeSAPLogonExt.PlugInName + " settings error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!SAPLogonHandler.ValidateSAPGUIPath(this.tbSAPGUIPath.Text))
            {
                MessageBox.Show(Translatable.ErrorMsgSAPGUIPath, KeeSAPLogonExt.PlugInName + " settings error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.DialogResult = DialogResult.OK;

            SaveOptions();
            this.Close();
        }
Esempio n. 6
0
        //---------------------------------------------------------------------------------------------------
        // Implementation: Detect SAP GUI installation automatically via Windows registry
        //---------------------------------------------------------------------------------------------------
        //***************************************************************************************************
        //*                                                                                                 *
        //*   Special thanks to ANatrix for the idea how to retrieve SAPGUI installation path.              *
        //*                                                                                                 *
        //***************************************************************************************************
        #region SAPGUIDetection

        public static string DetectSAPGUIPath()
        {
            RegistryKey rootKey = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, "");
            RegistryKey subKey  = null;

            bool   foundPath = true;
            object objPath;
            string sPath   = "";
            string resPath = "";

            try
            {
                // Check path from registry for x86
                subKey  = rootKey.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" + SAPGUIShortCutEXE);
                objPath = subKey.GetValue("Path");
                sPath   = Convert.ToString(objPath);
            }
            catch
            {
                foundPath = false;
            };

            if (!foundPath)
            {
                try
                {
                    // Check path from registry for 64bit
                    subKey  = rootKey.OpenSubKey("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" + SAPGUIShortCutEXE);
                    objPath = subKey.GetValue("Path");
                    sPath   = Convert.ToString(objPath);
                }
                catch
                {
                    foundPath = false;
                }
            }

            if (foundPath)
            {
                for (int i = 0; ((i < sPath.Length) && (sPath[i] != ';')); i++)
                {
                    resPath += sPath[i].ToString();
                }

                if (resPath.Length < 3)  // "C:\"
                {
                    foundPath = false;
                }
                else
                {
                    if (SAPLogonHandler.ValidateSAPGUIPath(resPath))
                    {
                        return(resPath);
                    }
                }
            }
            else
            {
                MessageBox.Show("SAPGUI not installed!", KeeSAPLogonExt.PlugInName + " settings error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(resPath);
        } //DetectSAPGUIPath