Exemple #1
0
        public bool AddSessionHostCredentials(EnterpriseHostSessionCredentials credentials)
        {
            var success = false;

            using (var db = new MyrtilleEnterpriseDBContext())
            {
                var session = db.Session.FirstOrDefault(m => m.SessionID == credentials.SessionID);
                if (session != null && db.Host.Any(m => m.ID == credentials.HostID))
                {
                    var sessionHost = db.SessionHostCredentials.FirstOrDefault(m =>
                                                                               m.SessionID == session.ID &&
                                                                               m.HostID == credentials.HostID);

                    if (sessionHost != null)
                    {
                        db.SessionHostCredentials.Remove(sessionHost);
                    }

                    sessionHost = new SessionHostCredential
                    {
                        SessionID = session.ID,
                        HostID    = credentials.HostID,
                        Domain    = credentials.Domain,
                        Username  = credentials.Username,
                        Password  = CryptoHelper.AES_Encrypt(CryptoHelper.RDP_Encrypt(credentials.Password), credentials.SessionKey)
                    };

                    db.SessionHostCredentials.Add(sessionHost);
                    db.SaveChanges();
                    success = true;
                }
            }

            return(success);
        }
 public bool AddSessionHostCredentials(EnterpriseHostSessionCredentials credentials)
 {
     try
     {
         return(Channel.AddSessionHostCredentials(credentials));
     }
     catch (Exception exc)
     {
         Trace.TraceError("Failed to create session credentials for user({0})", exc);
         throw;
     }
 }
Exemple #3
0
 public bool AddSessionHostCredentials(EnterpriseHostSessionCredentials credentials)
 {
     try
     {
         Trace.TraceInformation("creating session credentials for {0}", credentials.Username);
         return(Program._enterpriseAdapter.AddSessionHostCredentials(credentials));
     }
     catch (Exception ex)
     {
         Trace.TraceError("Failed to set session credentials for user {0}, ({1})", credentials.Username, ex);
         return(false);
     }
 }
Exemple #4
0
        /// <summary>
        /// Add override credentials for specific session host
        /// </summary>
        /// <param name="credentials"></param>
        /// <returns></returns>
        public bool AddSessionHostCredentials(EnterpriseHostSessionCredentials credentials)
        {
            using (var db = new MyrtilleEnterpriseDBContext())
            {
                var session = db.Session.FirstOrDefault(m => m.SessionID == credentials.SessionID);

                if (session == null)
                {
                    return(false);
                }

                if (!db.Host.Any(m => m.ID == credentials.HostID))
                {
                    return(false);
                }

                var sessionHost = db.SessionHostCredentials.FirstOrDefault(m => m.SessionID == session.ID &&
                                                                           m.HostID == m.HostID);

                if (sessionHost != null)
                {
                    db.SessionHostCredentials.Remove(sessionHost);
                }

                sessionHost = new SessionHostCredential
                {
                    SessionID = session.ID,
                    HostID    = credentials.HostID,
                    Username  = credentials.Username,
                    Password  = AES_Encrypt(RDPCryptoHelper.EncryptPassword(credentials.Password), credentials.SessionKey),
                };


                db.SessionHostCredentials.Add(sessionHost);
                db.SaveChanges();

                return(true);
            }
        }
Exemple #5
0
        /// <summary>
        /// create session host credentials and connect
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ConnectButtonClick(
            object sender,
            EventArgs e)
        {
            if (_enterpriseClient == null || _enterpriseSession == null || _hostId == 0)
            {
                return;
            }

            try
            {
                var enterpriseCredentials = new EnterpriseHostSessionCredentials
                {
                    HostID     = _hostId,
                    SessionID  = _enterpriseSession.SessionID,
                    SessionKey = _enterpriseSession.SessionKey,
                    Username   = promptUserName.Value,
                    Password   = promptPassword.Value
                };

                if (!_enterpriseClient.AddSessionHostCredentials(enterpriseCredentials))
                {
                    throw new Exception("Failed to add session host credentials");
                }


                // connect to remote host
                Response.Redirect(Request.RawUrl + (Request.RawUrl.Contains("?") ? "&" : "?") + "edit=success", false);
            }
            catch (ThreadAbortException)
            {
                // occurs because the response is ended after redirect
            }
            catch (Exception exc)
            {
                System.Diagnostics.Trace.TraceError("Failed to create host session credentials ({0})", exc);
            }
        }