Exemple #1
0
        public ActionResult Index(LoginInfo[] info)
        {
            string message = "";

            if (info != null)
            {
                HttpServerConnection cnx = IomFactory.CreateHttpServerConnection(info[0].網路位址, info[0].資料庫名稱, info[0].帳號, info[0].密碼);
                Item login_result        = cnx.Login();
                if (login_result.isError())
                {
                    message = "登入失敗:" + login_result.getErrorString();
                }
                else
                {
                    message = "登入成功";
                    Session["innovator"] = login_result.getInnovator();

                    string uID = login_result.getInnovator().getUserID();
                    Session["user_id"]   = uID;
                    Session["user_name"] = login_result.getInnovator().getItemById("User", uID).getProperty("keyed_name", "");
                }
                TempData["Result"] = message;

                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemple #2
0
        public string LoginToInnovator(string innovatorUrl, string database, string userName, string password)
        {
            HttpServerConnection serverConnection = null;

            using (new WaitingCursor())
            {
                try
                {
                    serverConnection = IomFactory.CreateHttpServerConnection(innovatorUrl, database, userName, Innovator.ScalcMD5(password));

                    var result = serverConnection.Login();
                    if (result.isError())
                    {
                        serverConnection = null;
                        return(result.getErrorString());
                    }
                }
                catch (Exception ex)
                {
                    serverConnection = null;
                    return(ex.Message);
                }
            }

            innovatorInstance = new Innovator(serverConnection);
            IsLoggedIn        = true;
            return(string.Empty);
        }
        public override void Connect(IReadOnlyCollection <Component> instanceComponents)
        {
            Logger.Instance.Log(LogLevel.Info, "\nConfiguring components ({0}, {1}, {2}, {3}) to work with component({4}):\n", ESAgentComponentId, ESIndexComponentId, ESZookeeperComponentId, ESFileProcessorComponentId, DatabaseComponentId);

            ESAgentComponent         esAgent           = instanceComponents.Single(c => c.Id == ESAgentComponentId) as ESAgentComponent;
            ESIndexComponent         esIndex           = instanceComponents.Single(c => c.Id == ESIndexComponentId) as ESIndexComponent;
            ESZooKeeperComponent     esZooKeeper       = instanceComponents.Single(c => c.Id == ESZookeeperComponentId) as ESZooKeeperComponent;
            ESFileProcessorComponent esFileProcessor   = instanceComponents.Single(c => c.Id == ESFileProcessorComponentId) as ESFileProcessorComponent;
            DatabaseComponent        databaseComponent = instanceComponents.Single(c => c.Id == DatabaseComponentId) as DatabaseComponent;

            DropSolrIndex(esIndex);

            string serviceNameXPath = "/configuration/ServiceName";

            esFileProcessor.ServiceName = FileSystemFactory.GetFileSystem(esFileProcessor.ServerName).XmlHelper.XmlPeek(esFileProcessor.PathToConfig, serviceNameXPath);
            WindowsServiceHelper.StopService(esFileProcessor.ServerName, esFileProcessor.ServiceName);

            esAgent.ServiceName = FileSystemFactory.GetFileSystem(esAgent.ServerName).XmlHelper.XmlPeek(esAgent.PathToConfig, serviceNameXPath);
            WindowsServiceHelper.StopService(esAgent.ServerName, esAgent.ServiceName);

            esIndex.ServiceName = FileSystemFactory.GetFileSystem(esIndex.ServerName).XmlHelper.XmlPeek(esIndex.PathToConfig, serviceNameXPath);
            WindowsServiceHelper.StopService(esIndex.ServerName, esIndex.ServiceName);

            esZooKeeper.ServiceName = FileSystemFactory.GetFileSystem(esZooKeeper.ServerName).XmlHelper.XmlPeek(esZooKeeper.PathToConfig, serviceNameXPath);
            WindowsServiceHelper.StopService(esZooKeeper.ServerName, esZooKeeper.ServiceName);

            //Wait Until services are stopped for 30 seconds
            Thread.Sleep(30000);

            HttpServerConnection connection = IomFactory.CreateHttpServerConnection(databaseComponent.InnovatorUrl, databaseComponent.DatabaseName, databaseComponent.LoginOfRootInnovatorUser, databaseComponent.PasswordOfRootInnovatorUser.Value);

            try
            {
                connection.Login();

                Innovator innovator = new Innovator(connection);

                EditVariable(innovator, "ES_SolrUrl", esIndex.ESAIClusterUrl);
                EditVariable(innovator, "ES_AIClusterUrl", esIndex.ESAIClusterUrl);
                EditCryptoPwd(innovator, esAgent);
            }
            finally
            {
                connection.Logout();
            }

            UpdateESZooKeeperServiceConfig(esZooKeeper, databaseComponent);
            WindowsServiceHelper.StartService(esZooKeeper.ServerName, esZooKeeper.ServiceName);

            UpdateESIndexServiceConfig(esIndex, databaseComponent);
            WindowsServiceHelper.StartService(esIndex.ServerName, esIndex.ServiceName);

            UpdateESAgentServiceConfig(esAgent, databaseComponent);
            WindowsServiceHelper.StartService(esAgent.ServerName, esAgent.ServiceName);

            UpdateESFileProcessorServiceConfig(esFileProcessor, databaseComponent);
            WindowsServiceHelper.StartService(esFileProcessor.ServerName, esFileProcessor.ServiceName);

            ReloadSolrCollection(esIndex);
        }
Exemple #4
0
        string CreateFileItem(string URL, string database, string username, string password)
        {
            string filePath           = "C:\\temp\\TesTDocument1.doc";
            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(URL, database, username, password);
            Item login_result         = conn.Login();

            if (login_result.isError())
            {
                throw new Exception("Login failed");
            }
            Innovator inn = IomFactory.CreateInnovator(conn);

            Item fileItem = inn.newItem("File", "add");

            fileItem.setProperty("filename", new System.IO.FileInfo(filePath).Name);
            fileItem.attachPhysicalFile(filePath);
            Item result = fileItem.apply();

            conn.Logout();
            if (result.isError())
            {
                return(result.getErrorString());
            }
            else
            {
                return("Success!");
            }
        }
Exemple #5
0
        /// <summary>
        /// 自动完成
        /// </summary>
        public static WORKFLOW_PROCESS_PATH AutoCompleteActivityByParam(string id, string tableName, string lineName = "agree")
        {
            string url         = ConfigurationManager.AppSettings["ArasUrl"];
            string dbName      = ConfigurationManager.AppSettings["ArasDB"];
            string accountName = ConfigurationManager.AppSettings["Administrator"];
            string password    = ConfigurationManager.AppSettings["ArasPassword"];

            //使用管理员帐号登陆
            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, accountName, password);
            Item login_result         = conn.Login();

            if (!login_result.isError())
            {
                var  inn          = login_result.getInnovator();
                Item activityItem = ActivityDA.GetActivityByItemId(inn, id, "Administrators", tableName);
                if (!activityItem.isError())
                {
                    string activityId           = activityItem.getProperty("activityid");
                    string activityAssignmentId = activityItem.getProperty("activityassignmentid");
                    //任务路线
                    var listActivity = WorkflowProcessPathDA.GetWorkflowProcessPathByActivityId(activityId);
                    WORKFLOW_PROCESS_PATH choicePath = listActivity.Where(x => x.NAME == lineName).FirstOrDefault();
                    //替换符
                    ReplaceChars(choicePath);
                    string errorStr = ActivityDA.CompleteActivity(inn, activityId, activityAssignmentId, choicePath.ID, choicePath.NAME, "", "AutoComplete");
                    if (string.IsNullOrEmpty(errorStr))
                    {
                        return(choicePath);
                    }
                }
            }
            return(null);
        }
Exemple #6
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            string myTitle       = PRTitle.Text;
            string myDescription = PRDesc.Text;
            string mySteps2Rep   = PRStepsRepeat.Text;

            if (myTitle == "" || myDescription == "")
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "MyAlert", "<script>alert('Please fill in required fields of PR Title and PR Description!!!')</script>");
            }
            else
            {
                string url                = url_text.Text;
                string db                 = db_text.Text;
                string user               = user_text.Text;
                string password           = password_text.Text;
                HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, db, user, password);
                Item login_result         = conn.Login();
                if (login_result.isError())
                {
                    throw new Exception("Login failed:" + login_result.getErrorDetail());
                }
                Innovator inn  = IomFactory.CreateInnovator(conn);
                Item      myPR = inn.newItem("PR", "add");
                myPR.setProperty("title", myTitle);
                myPR.setProperty("description", myDescription);
                myPR.setProperty("events", mySteps2Rep);
                myPR.apply();

                conn.Logout();
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "MyAlert", "<script>alert('Your PR was created successfully!!!')</script>");
            }
        }
Exemple #7
0
        /// <summary>
        /// aras连接
        /// </summary>
        public Innovator ArasConnection(string userName, string password)
        {
            conn = IomFactory.CreateHttpServerConnection(url, DBName, userName, password);
            Item login_result = conn.Login();

            inn = login_result.getInnovator();
            return(inn);
        }
Exemple #8
0
        static void Main(string[] args)
        {
            connection = IomFactory.CreateHttpServerConnection(ConfigurationManager.AppSettings.Get("url"), ConfigurationManager.AppSettings.Get("database"), ConfigurationManager.AppSettings.Get("user"), ConfigurationManager.AppSettings.Get("password"));
            Item loginResult = connection.Login();

            if (!loginResult.isError())
            {
                TransferToSAP();
            }
        }
Exemple #9
0
        private static HttpServerConnection _Login(string usr, string pwd, string url, string db)
        {
            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, db, usr, Innovator.ScalcMD5(pwd));
            Item logResult            = conn.Login();

            if (logResult.isError())
            {
                throw new Exception("Failed to login to Innovator");
            }

            return(conn);
        }
Exemple #10
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string url  = txtPLMIP.Text;
            string db   = txtPLMDB.Text;
            string user = txtPLMAD.Text;
            string pw   = txtPLMPWD.Text;
            HttpServerConnection cnx = IomFactory.CreateHttpServerConnection(url, db, user, pw);
            Item login_result        = cnx.Login();

            if (!login_result.isError())
            {
                inn = IomFactory.CreateInnovator(cnx);
                MessageBox.Show("Login OK!");
            }
        }
Exemple #11
0
        void login(string url, string db, string uname, string pwd)
        {
            HttpServerConnection conn = Aras.IOM.IomFactory.CreateHttpServerConnection(url, db, uname, pwd);

            Console.WriteLine("Trying to login as '{0}'...", uname);
            Item log_result = conn.Login();

            if (log_result.isError())
            {
                throw new Exception("Failed login to Innovator");
            }

            this.inn = new Innovator(conn);

            Console.WriteLine("Logged in as user '{0}'", uname);
        }
Exemple #12
0
        /// <summary>
        ///  登陆获取用户信息
        /// </summary>
        /// <param name="loginName"></param>
        public static void LogIn(string loginName, UserInfo user)
        {
            string url    = ConfigurationManager.AppSettings["ArasUrl"];
            string dbName = ConfigurationManager.AppSettings["ArasDB"];

            //获取用户信息
            USER userObJ = UserDA.GetUserByLoginName(loginName);

            if (userObJ != null)
            {
                user.UserId      = userObJ.ID;
                user.UserName    = userObJ.KEYED_NAME;
                user.LoginName   = userObJ.LOGIN_NAME;
                user.Password    = userObJ.PASSWORD;
                user.b_JobNumber = userObJ.B_JOBNUMBER;
                user.Email       = userObJ.EMAIL;
                HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, user.LoginName, user.Password);
                Item login_result         = conn.Login();
                if (login_result.isError())
                {
                    if (conn != null)
                    {
                        conn.Logout();
                    }
                }
                else
                {
                    var inn = login_result.getInnovator();
                    if (inn != null)
                    {
                        //获取当前角色身份
                        List <string> listRoles = IdentityDA.getIdentityListByUserID(inn, user.UserId);
                        user.Roles = listRoles;

                        if ((user.AgentAuth == null && user.AgentCreateTime == null) || (user.AgentCreateTime != null))
                        {
                            List <AgentSetEntity> AgentSetList = AgentSetBll.GetAgentSetByUserName(user.UserName);
                            if (AgentSetList.Count > 0)
                            {
                                AgentSetBll.GetAgentRoles(inn, user, AgentSetList);
                            }
                        }
                        user.inn = inn;
                    }
                }
            }
        }
Exemple #13
0
 public Boolean PLM_Login(string url, string db, string user, string pw)
 {
     try
     {
         //Debugger.Break();
         HttpServerConnection cnx = IomFactory.CreateHttpServerConnection(url, db, user, pw);
         Item login_result        = cnx.Login();
         if (!login_result.isError())
         {
             CoInnovator = IomFactory.CreateInnovator(cnx);
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #14
0
        /// <summary>
        /// Returns an HttpServerConnection for the selected instance
        /// </summary>
        /// <param name="url"></param>
        /// <param name="Db"></param>
        /// <param name="InnUser"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        private HttpServerConnection MyIConnection(string url, string Db, string InnUser, string Password)
        {
            HttpServerConnection connection = IomFactory.CreateHttpServerConnection(url, Db, InnUser, Password);

            Item Login = connection.Login();

            if (!Login.isError())
            {
                isConnected        = true;
                inn                = Login.getInnovator();
                btnExecute.Enabled = true;
            }
            else
            {
                btnExecute.Enabled = false;
            }
            return(connection);
        }
Exemple #15
0
        /// <summary>
        /// 获取Admin 登录连接
        /// </summary>
        /// <returns></returns>
        public static Innovator GetAdminInnovator()
        {
            string url         = ConfigurationManager.AppSettings["ArasUrl"];
            string dbName      = ConfigurationManager.AppSettings["ArasDB"];
            string accountName = ConfigurationManager.AppSettings["Administrator"];
            string password    = ConfigurationManager.AppSettings["ArasPassword"];

            //使用管理员帐号登陆
            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, accountName, password);
            Item login_result         = conn.Login();

            if (!login_result.isError())
            {
                var inn = login_result.getInnovator();
                return(inn);
            }
            return(null);
        }
        private void loginBtn_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            _conn = IomFactory.CreateHttpServerConnection(textBoxURL.Text, cmbDatabase.Text, textBoxLogin.Text, textBoxPassword.Text);
            Item result = _conn.Login();

            if (result.isError())
            {
                MessageBox.Show(string.Format("Login failed with error: {0}", result.getErrorString()), "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.m_inn = IomFactory.CreateInnovator(_conn);

            btnRunSearch.Enabled = true;
            loginBtn.Enabled     = false;
        }
        /// <summary>
        /// Logon to Innovator.
        /// </summary>
        /// <param name="userName">string</param>
        /// <param name="userPassword">string</param>
        /// <param name="locale">string</param>
        /// <param name="timeZone">string</param>
        private void _Login(string userName, string userPassword, string locale, string timeZone)
        {
            string url = string.Format(CultureInfo.InvariantCulture, "{0}/server/innovatorserver.aspx", System.Configuration.ConfigurationSettings.AppSettings["url"]);
            string db  = System.Configuration.ConfigurationSettings.AppSettings["db"];

            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, db, userName, Innovator.ScalcMD5(userPassword));

            SetLocale(conn, locale, timeZone);

            Item logResult = conn.Login();

            if (logResult.isError())
            {
                throw new LogOnException("Failed to logon to Innovator");
            }

            inn = new Innovator(conn);
        }
        internal static HttpServerConnection GetServerConnection(DatabaseComponent databaseComponent)
        {
            if (Instance._usedServerConnections.ContainsKey(databaseComponent.Id))
            {
                return(Instance._usedServerConnections[databaseComponent.Id]);
            }

            HttpServerConnection serverConnection = IomFactory.CreateHttpServerConnection(
                databaseComponent.InnovatorUrl,
                databaseComponent.DatabaseName,
                databaseComponent.LoginOfRootInnovatorUser,
                databaseComponent.PasswordOfRootInnovatorUser.Value);

            serverConnection.Login();

            Instance._usedServerConnections.Add(databaseComponent.Id, serverConnection);

            return(serverConnection);
        }
 public Aras.IOM.Innovator getInnovatorObject(string url = "****", string db = "Production", string user = "******", string password = "******") //cBfvyGLm3uGZxwan ChillPenguin
 {
     Console.WriteLine("URL:" + url + " DB:" + db + " User:"******" Continue? y or n");
     if (Console.ReadLine().ToLower() == "y")
     {
         this.conn = IomFactory.CreateHttpServerConnection(url, db, user, password);
         Item login_result = conn.Login();
         if (login_result.isError())
         {
             throw new Exception("Login failed");
         }
         Aras.IOM.Innovator inn = IomFactory.CreateInnovator(conn);
         Console.WriteLine("Seems we have a connection");
         return(inn);
     }
     else
     {
         throw new Exception("User refused to connect");
     }
 }
        public bool Login(string serverURL, string database, string username, string password)
        {
            this.serverURL = serverURL;
            this.database  = database;
            this.username  = username;
            this.password  = password;

            connection = IomFactory.CreateHttpServerConnection(serverURL, database, username, password);
            lastError  = "";

            Item rv = connection.Login();

            if (SetError(rv))
            {
                connection = null;
                return(false);
            }

            innovator = new Innovator(connection);
            return(true);
        }
 private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         HttpServerConnection cnx = IomFactory.CreateHttpServerConnection(txtIP.Text, txtDB.Text, txtID.Text, txtPassword.Text);
         Item login_result        = cnx.Login();
         if (!login_result.isError())
         {
             inn         = IomFactory.CreateInnovator(cnx);
             txtAML.Text = "Login success";
             return;
         }
         message     = login_result.getErrorString();
         txtAML.Text = message;
     }
     catch (Exception ex)
     {
         message     = ex.ToString();
         txtAML.Text = message;
     }
 }
        //------------------------------------------------------------------------------------------------------

        private void btn_ConnectionAras_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txt_serverurl.Text.Trim()))
                {
                    throw new Exception("Server Url Is Null Or Empty !");
                }

                if (string.IsNullOrEmpty(txt_DB.Text.Trim()))
                {
                    throw new Exception("DB Name Is Null Or Empty !");
                }

                if (string.IsNullOrEmpty(txt_username.Text.Trim()))
                {
                    throw new Exception("User Name Is Null Or Empty !");
                }

                if (string.IsNullOrEmpty(txt_password.Text.Trim()))
                {
                    throw new Exception("Password Is Null Or Empty !");
                }

                GetConnection(txt_serverurl.Text, txt_DB.Text, txt_username.Text, txt_password.Text);
                GetInnovator();

                Item login_result = mc_conn.Login();
                if (login_result.isError())
                {
                    throw new Exception("Login failed, please check connection infomation.");
                }

                SettingConnectionButton(true);
            }
            catch (Exception ex)
            {
                ShowError("Connection Aras Error:" + ex.Message);
            }
        }
Exemple #23
0
 public static bool LogIn(string pUrl, string pDBName, string pUserName, string pPassword, ref string strError)
 {
     try
     {
         connection = IomFactory.CreateHttpServerConnection(pUrl, pDBName, pUserName, pPassword);
         Item result = connection.Login();
         if (result.isError())
         {
             if (connection != null)
             {
                 connection.Logout();
             }
             string str        = result.getErrorString();
             int    startIndex = (str.IndexOf(":") + 1);
             if (startIndex > 0)
             {
                 str = str.Substring(startIndex);
             }
             if (str.Contains("Authentication"))
             {
                 str = "Invalid user or password";
             }
             strError = str;
             return(false);
         }
         else
         {
             inn = result.getInnovator();
             return(true);
         }
     }
     catch (Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
        private void loginBtn_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            _conn = IomFactory.CreateHttpServerConnection(textBoxURL.Text, cmbDatabase.Text, textBoxLogin.Text, textBoxPassword.Text);
            Item result = _conn.Login();
            if (result.isError())
            {
                MessageBox.Show(string.Format("Login failed with error: {0}", result.getErrorString()), "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.m_inn = IomFactory.CreateInnovator(_conn);

            btnRunSearch.Enabled = true;
            loginBtn.Enabled = false;
        }
Exemple #25
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            var oldCursor = Cursor;

            Cursor = Cursors.WaitCursor;

            _user     = txtUser.Text;
            _password = txtPassword.Text;
            _url      = txtUrl.Text;
            _db       = cmbDatabase.Text;

            //write config file
            SaveConfig();

            _conn = IomFactory.CreateHttpServerConnection(_url, _db, _user, _password);

            Item login_result = _conn.Login();

            Cursor = oldCursor;

            if (login_result.isError())
            {
                //if already connected the logout of previous connection
                if (_conn != null)
                {
                    _conn.Logout();
                }

                //get details of error
                string error_str = login_result.getErrorString();


                //Interpret message string  - remove header text before : symbol
                int pos = error_str.IndexOf(':') + 1;
                if (pos > 0)
                {
                    error_str = error_str.Substring(pos);
                }
                //If error contains keyword clean up message text
                if (error_str.Contains("Authentication"))
                {
                    error_str = "Invalid user or password";
                }

                if (error_str.Contains("Database"))
                {
                    error_str = "Database not available";
                }

                MessageBox.Show("Login failed!\r\n\r\n" + error_str, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            lblFileName.Enabled = true;
            btnLogin.Enabled    = false;
            btnFileOpen.Enabled = true;
            btnLoad.Enabled     = true;

            txtUrl.Enabled          = false;
            txtUser.Enabled         = false;
            txtPassword.Enabled     = false;
            cmbDatabase.Enabled     = false;
            btnGetDatabases.Enabled = false;

            //Get innovator object
            _inn = IomFactory.CreateInnovator(_conn);
        }
        /// <summary>
        /// 登入(Login)
        /// </summary>
        /// <param name="pUrl">URL</param>
        /// <param name="pDBName">DBName</param>
        /// <param name="pUserName">UserName</param>
        /// <param name="pPassword">Password</param>
        /// <returns></returns>
        public ActionResult LogIn()
        {
            //判断当前系统语言
            string language = Request.Headers["Accept-Language"].ToString();

            language = language.Split(',')[0].ToString();
            if (language.IndexOf("en") >= 0)
            {
                language = "English";
            }
            else
            {
                language = "Chinese";
            }

            string url        = ConfigurationManager.AppSettings["ArasUrl"];
            string dbName     = ConfigurationManager.AppSettings["ArasDB"];
            string username   = Request.Form["Username"];
            string password   = Request.Form["Password"];
            string ChoicePath = Request.Form["ChoicePath"];
            string str        = "";

            try
            {
                //string DomainKey = "admin";
                //string ForceSha = "0";
                //string passwordStr = CommonMethod.md5string16(DomainKey, ForceSha == "1" ? true : false) + CommonMethod.md5string16(username.ToLower(), ForceSha == "1" ? true : false) + username.ToLower() + DomainKey;
                //HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, username, password);
                //Item login_result = conn.Login();
                //if (login_result.isError())
                //{
                //}
                //strPassword = md5string16(DomainKey, IIf(ForceSha = "1", True, False)) + md5string16(strUserName.ToLower(), IIf(ForceSha = "1", True, False)) + strUserName.ToLower() + DomainKey 参考代码
                UserInfo user     = new UserInfo();
                string   errorMsg = "";
                //if (username == "admin")
                //{
                //    HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, username, password);
                //    Item login_result = conn.Login();
                //    if (login_result.isError())
                //    {
                //        if (conn != null) { conn.Logout(); }
                //        str = login_result.getErrorString();
                //        int startIndex = (str.IndexOf(":") + 1);
                //        if (startIndex > 0) { str = str.Substring(startIndex); }
                //        if (str.Contains("Authentication")) { str = "Invalid user or password"; }
                //    }
                //    else
                //    {
                //        errorMsg = "AD Login OK";
                //    }
                //}
                //else
                //{
                //    errorMsg = LoginAD(username, password);
                //}
                errorMsg = "AD Login OK";
                if (errorMsg == "AD Login OK")
                {
                    //获取用户信息
                    USER userObJ = UserDA.GetUserByLoginName(username);
                    // 创建登录凭证

                    user.UserId              = userObJ.ID;
                    user.UserName            = userObJ.KEYED_NAME;
                    user.LoginName           = userObJ.LOGIN_NAME;
                    user.Password            = userObJ.PASSWORD;
                    user.HTTP_USER_AGENT     = Request.UserAgent;
                    user.UserIp              = Request.UserHostAddress;
                    user.b_JobNumber         = userObJ.B_JOBNUMBER;
                    user.Email               = userObJ.EMAIL;
                    user.language            = language;
                    user.b_AffiliatedCompany = userObJ.B_AFFILIATEDCOMPANY;

                    //获取AD域中的信息
                    CommonMethod.GetAdInfoByUser(user, "bordrin.com");

                    user.ExpireDate = DateTime.Now.AddDays(1);
                    //Innovator.ScalcMD5(user.Password)
                    HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, dbName, user.LoginName, user.Password);
                    Item login_result         = conn.Login();
                    if (login_result.isError())
                    {
                        if (conn != null)
                        {
                            conn.Logout();
                        }
                        str = login_result.getErrorString();
                        int startIndex = (str.IndexOf(":") + 1);
                        if (startIndex > 0)
                        {
                            str = str.Substring(startIndex);
                        }
                        if (str.Contains("Authentication"))
                        {
                            str = "Invalid user or password";
                        }
                    }
                    else
                    {
                        var inn = login_result.getInnovator();
                        //string token = Guid.NewGuid().ToString("N").ToUpper();
                        //获取当前角色身份
                        List <string> listRoles = IdentityDA.getIdentityListByUserID(inn, user.UserId);
                        user.Roles = listRoles;
                        //获取当前权限信息
                        if (user.MemuAuth == null)
                        {
                            user.MemuAuth = new List <string>();
                            for (int j = 0; j < listRoles.Count; j++)
                            {
                                string id = listRoles[j];
                                //根据Id获取权限列表
                                Item ItemTypes = ItemTypeDA.GetMenuAuthByIdentity(inn, id);
                                if (ItemTypes.getItemCount() > 0)
                                {
                                    for (int i = 0; i < ItemTypes.getItemCount(); i++)
                                    {
                                        Item   itemobj  = ItemTypes.getItemByIndex(i);
                                        string itemName = itemobj.getProperty("name");
                                        if (user.MemuAuth.IndexOf(itemName) < 0)
                                        {
                                            user.MemuAuth.Add(itemName);
                                        }
                                    }
                                }
                            }
                        }
                        user.inn = inn;

                        //获取委托的权限数据
                        DateTime currentTime = DateTime.Now.AddMinutes(-10);
                        if ((user.AgentAuth == null && user.AgentCreateTime == null) || (user.AgentCreateTime != null && currentTime > user.AgentCreateTime))
                        {
                            List <AgentSetEntity> AgentSetList = AgentSetBll.GetAgentSetByUserName(user.UserName);
                            if (AgentSetList.Count > 0)
                            {
                                AgentSetBll.GetAgentRoles(inn, user, AgentSetList);
                            }
                        }


                        UserBll.SaveUserInfoToCache(user);
                        // 设置用户 cookie
                        HttpCookie cookie = new HttpCookie("Passport.Token");
                        cookie.Value   = user.LoginName;
                        cookie.Expires = DateTime.Now.AddHours(8);
                        cookie.Secure  = FormsAuthentication.RequireSSL;
                        Response.Cookies.Add(cookie);
                        if (ChoicePath == "0")
                        {
                            return(Redirect("/Portal/Index"));
                        }
                        else
                        {
                            return(Redirect("/Home/Index"));
                        }
                    }
                }
                else
                {
                    str = "Invalid user or password";
                }
            }
            catch (Exception ex)
            {
                str = "Invalid user or password";
            }
            return(RedirectToAction("Index", "Login", new { errorStr = str, isAdLogin = false }));
        }