Esempio n. 1
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. 2
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. 3
0
        public static bool DoLogon(LogonColumn logonPoint, ProtectedString user, ProtectedString password)
        {
            if (ValidateSAPGUIPath(m_sapguiPath) && logonPoint.IsValid())
            {
                //Example:
                //
                // "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapshcut" -system=ABC -client=010 -user=username -pw=pass -language=EN -maxgui -command=SE10
                //

                string strArgs = "-maxgui";

                Dictionary <string, string> args = new Dictionary <string, string>();
                args.Add("-system", logonPoint.SAPID);
                args.Add("-client", logonPoint.SAPClient);
                args.Add("-user", user.ReadString());
                args.Add("-pw", password.ReadString());
                args.Add("-language", logonPoint.SAPLanguage);
                args.Add("-command", logonPoint.SAPTransaction);

                foreach (string key in args.Keys)
                {
                    string value;
                    args.TryGetValue(key, out value);
                    strArgs = strArgs + " ";
                    strArgs = strArgs + key + "=" + value;
                }

                string           fileLoc  = Path.Combine(m_sapguiPath, SAPLogonHandler.SAPGUIShortCutEXE);
                FileInfo         fileInfo = new FileInfo(fileLoc);
                ProcessStartInfo info     = new ProcessStartInfo(fileInfo.FullName);
                info.Arguments              = strArgs;
                info.CreateNoWindow         = false;
                info.UseShellExecute        = true;
                info.ErrorDialog            = true;
                info.RedirectStandardInput  = false;
                info.RedirectStandardOutput = false;

                Process process = Process.Start(info);

                return(!(process.HasExited));
            }

            return(false);
        }