Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            SecurityClient client = new SecurityClient("ISecuritySoap11");

            LoginRequest loginRequest = new LoginRequest();

            loginRequest.computerId = MainWindow.id;
            loginRequest.login      = this.textBox1.Text;
            loginRequest.password   = this.textBox2.Text;

            try
            {
                LoginResponse response = client.Login(loginRequest);
                MainWindow.Session = response.session;
            }
            catch (Exception ex)
            {
                this.label1.Text = "Wrong login or password";
                return;
            }
            close = true;
//            try
//            {
//                Process[] proc = Process.GetProcessesByName("winword");
//                foreach (Process element in proc)
//                {
//                    Console.WriteLine(proc.Length);
//                    element.Kill();
//                }
//            }
//            catch (Exception ex)
//            {
//            }
            msgBox.Close();
        }
Esempio n. 2
0
        protected void Initialize(string baseAddress, TimeSpan commandTimeout, string username = "", string password = "")
        {
            Client             = new HttpClient();
            Client.BaseAddress = new Uri(baseAddress);
            Client.Timeout     = commandTimeout;

            Token = null;

            Security    = new SecurityClient(this);
            Schema      = new SchemaClient(this);
            Transaction = new TransactionClient(this);
            Document    = new DocumentClient(this);
            Query       = new QueryClient(this);

            if (string.IsNullOrWhiteSpace(username) == false)
            {
                Security.Login(username, password);
            }
        }
        public ActionResult DoAuthenticate(UserCredentialViewModel userCredential)
        {
            ViewBag.Message = "Welcome User!";

            /*
             * Making our first request to validated user credential
             * 1) On success we get the security-token
             * 2) Place the security token in cookie so that it could be used on subsequent request which ever requires it for authentication
             */
            var result = securityClient.Login(userCredential.UserName, userCredential.Password);

            if (result.LoginSuccess)
            {
                Response.Cookies.Add(new HttpCookie("STKN", result.SecurityToken));
            }
            else
            {
                ViewBag.Message = "Login failed!";
            }

            return(View("Index"));
        }