Example #1
0
        public void DiffEntities()
        {
            Dictionary <string, string> attributesData  = new Dictionary <string, string>();
            RetrieveAllEntitiesRequest  metaDataRequest = new RetrieveAllEntitiesRequest();

            metaDataRequest.EntityFilters = EntityFilters.All;

            // Execute the request.

            var entities1 = ((RetrieveAllEntitiesResponse)LeftService.Execute(metaDataRequest)).EntityMetadata;
            var entities2 = ((RetrieveAllEntitiesResponse)RightService.Execute(metaDataRequest)).EntityMetadata;

            mainForm.ProgressStart("Entities", 1, entities1.Length);

            foreach (var emd1 in entities1)
            {
                var emd2 = entities2.Where(x => x.LogicalName == emd1.LogicalName).FirstOrDefault();

                if (emd2 != null && emd1.IsCustomizable.Value)
                {
                    DiffEntity(emd1, emd2);
                }


                mainForm.ProgressPerformStep();
            }
        }
Example #2
0
        public virtual void CustomizeForUser(EditorItem <T> page)
        {
            List <Right>      rights   = null;
            PrivilegeObserver observer = new PrivilegeObserver();

            if (!ApplicationManager.User.IsAdmin() && page.EditedObject.oid.HasValue)
            {
                RightService service = ApplicationManager.ControllerFactory.ServiceFactory.GetRightService();
                rights = service.getUserRights(this.SubjectType.label, page.EditedObject.oid.Value);
            }
            if (this.ToolBar != null)
            {
                this.ToolBar.Customize(this.FunctionalityCode, observer, rights, page.IsReadOnly);
            }
            if (this.SideBar != null)
            {
                this.SideBar.Customize(rights, page.IsReadOnly);
            }
            CustomizeContexMenu(observer, rights, page);

            bool edit = RightsUtil.HasRight(Domain.RightType.EDIT, rights);

            page.CanRename = edit && !page.IsReadOnly;
            page.CanSave   = edit;
        }
Example #3
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.HttpContext.User.Identity.IsAuthenticated == true)
            {
                var userId  = filterContext.HttpContext.User.Identity.GetUserId();
                var service = new RightService();

                bool tran = false;
                if (!service.IsUserHasRightById(userId, Right))
                {
                    tran = true;
                }
                if (service.IsUserHasRightById(userId, "Admin right"))
                {
                    tran = false;
                }

                if (tran)
                {
                    filterContext.Result = new RedirectResult("/Home/NotAuthorized");
                }
            }
            else
            {
                filterContext.Result = new RedirectResult("/Account/NotAuthorized");
            }
            base.OnActionExecuting(filterContext);
        }
Example #4
0
        private void customizeContextMenuForSelection()
        {
            int  count         = this.GetBrowser().Form.Grid.SelectedItems.Count;
            bool itemsSelected = count > 0;

            bool create = true;
            bool saveAs = count == 1;
            bool delete = count == 1;

            if (count == 1)
            {
                BrowserData       item     = (BrowserData)this.GetBrowser().Form.Grid.SelectedItem;
                List <Right>      rights   = null;
                PrivilegeObserver observer = new PrivilegeObserver();
                if (!ApplicationManager.User.IsAdmin())
                {
                    RightService service = ApplicationManager.ControllerFactory.ServiceFactory.GetRightService();
                    rights = service.getUserRights(this.SubjectType.label, item.oid);
                }
                saveAs = RightsUtil.HasRight(Domain.RightType.SAVE_AS, rights);
                delete = RightsUtil.HasRight(Domain.RightType.DELETE, rights);
                create = observer.hasPrivilege(this.FunctionalityCode, Domain.RightType.CREATE);
            }
            this.GetBrowser().Form.Grid.NewMenuItem.IsEnabled  = create;
            this.GetBrowser().Form.Grid.OpenMenuItem.IsEnabled = itemsSelected;
            //this.GetBrowser().Form.Grid.RenameMenuItem.IsEnabled = saveAs && count == 1;
            this.GetBrowser().Form.Grid.SaveAsMenuItem.IsEnabled = saveAs && count == 1;
            //this.GetBrowser().Form.Grid.CopyMenuItem.IsEnabled = itemsSelected && create;
            //this.GetBrowser().Form.Grid.PasteMenuItem.IsEnabled = create;
            this.GetBrowser().Form.Grid.DeleteMenuItem.IsEnabled = itemsSelected && delete;
            customizeContextMenu();
        }
Example #5
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string loginName = txtLoginName.Text.Trim();
        string loginPwd = txtPassword.Text;
        RightService server = new RightService();
        int result= server.Login(loginName , loginPwd.GetMD5());
        if (result == 0) {
            UserDetail user = server.GetUserCompleteDetail(loginName);
            //log
            AppLog.Write(string.Format("[login] {0} 登录成功" , loginName) , AppLog.LogMessageType.Info);
            bool existsCode = RepositoryFactory<Employees>.Get().ExistsCode(user.EmployeeCode);
            string redirectUrl = Request.QueryString["ReturnUrl"] ?? "default.htm";
            if (existsCode) {
                //授权 登录
                Helper.SetAuthCookie(user.EmployeeCode , false , HttpContext.Current);

                //log
                //AppLog.Write(string.Format("[login] {0} 登录成功" , loginName) , AppLog.LogMessageType.Info);

                Response.Redirect(redirectUrl , true);
            } else {
                //第一次登陆,跳转设置专业信息
                redirectUrl = string.Format("InitProfile.aspx?name={0}&uc={1}&ReturnUrl={2}" , Server.UrlEncode(loginName) , Server.UrlEncode(user.EmployeeCode) , Server.UrlEncode(redirectUrl));
                Response.Redirect(redirectUrl,true);
            }
        } else {
            ltmsg.Text = Helper.LoginResult[result];
        }
    }
Example #6
0
 /// <summary>
 /// Gets RightService
 /// </summary>
 public RightService GetRightService()
 {
     if (rightService == null)
     {
         rightService = new RightService();
         rightService.ResourcePath = AdministrationResourcePath.SECURITY_RIGHT_RESOURCE_PATH;
         configureService(rightService);
     }
     return(rightService);
 }
Example #7
0
 public ChapterController(
     RightService rightService,
     DbCompositionService compositionService,
     UserManager <User> userManager,
     DbChapterService chapterService)
 {
     _rightService       = rightService;
     _compositionService = compositionService;
     _userManager        = userManager;
     _chapterService     = chapterService;
 }
        /// <summary>
        /// Check user has certain right
        /// </summary>
        /// <param name="right"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static bool IsHasRihgt(string right, string userId)
        {
            var service = new RightService();

            if (service.IsUserHasRightById(userId, "Admin right"))
            {
                return(true);
            }

            return(service.IsUserHasRightById(userId, right));
        }
Example #9
0
        /// <summary>
        /// Crée et rajoute la page d'édition d'un objet donné.
        /// </summary>
        /// <param name="anObject">L'objet dont la page doit être rejoutée</param>
        /// <returns>La page créée</returns>
        protected virtual EditorItem <T> addPage(T anObject, bool readOnly = false, List <Domain.Right> rights = null)
        {
            if (!ApplicationManager.Instance.User.IsAdmin() && anObject != null && anObject.oid.HasValue)
            {
                RightService service = ApplicationManager.Instance.ControllerFactory.ServiceFactory.GetRightService();
                rights = service.getUserRights(this.SubjectType.label, anObject.oid.Value);
            }

            EditorItem <T> page = getNewPage();

            if (readOnly)
            {
                page.SetReadOnly(readOnly);
            }
            page.ChangeEventHandler = this.ChangeEventHandler;
            page.EditedObject       = anObject;
            page.Title = anObject != null?anObject.ToString() : "";

            page.Customize(rights, readOnly);
            page.displayObject();
            page.IsActiveChanged += ActivePageChangedEventHandler;
            bool canAddNewPage = NewPage != null;

            if (canAddNewPage)
            {
                NewPage.IsActiveChanged -= newPageEventHandler;
            }

            try
            {
                if (canAddNewPage)
                {
                    this.Children.Remove(NewPage);
                }
                this.Children.Add(page);
                if (canAddNewPage)
                {
                    this.Children.Add(NewPage);
                }
            }
            catch (Exception)
            {
            }
            page.IsActive = true;
            if (canAddNewPage)
            {
                NewPage.IsActiveChanged += newPageEventHandler;
            }
            return(page);
        }
Example #10
0
        public void DiffForms()
        {
            #region Forms

            var qe = new QueryExpression("systemform");
            qe.Criteria.AddCondition(new ConditionExpression("ismanaged", ConditionOperator.Equal, false));
            qe.ColumnSet = new ColumnSet("name", "publishedon", "type", "objecttypecode");

            var forms1 = LeftService.RetrieveMultiple(qe).Entities;
            var forms2 = RightService.RetrieveMultiple(qe).Entities;

            List <ComponentDiff <Entity> > formsDiff = new List <ComponentDiff <Entity> >();

            mainForm.ProgressStart("Forms", 1, forms1.Count + forms2.Count);
            foreach (var f1 in forms1)
            {
                var f2 = forms2.Where(x => x.Id == f1.Id).FirstOrDefault();
                if (f2 == null)
                {
                    _diffResult.Forms.Add(new ComponentDiff <Entity>()
                    {
                        EntityName = f1.GetAttributeValue <string>("objecttypecode"),
                        Name       = f1.GetAttributeValue <string>("name"),
                        Left       = f1,
                    });
                }
                mainForm.ProgressPerformStep();
            }
            foreach (var f2 in forms2)
            {
                var f1 = forms1.Where(x => x.Id == f2.Id).FirstOrDefault();
                if (f1 == null)
                {
                    _diffResult.Forms.Add(new ComponentDiff <Entity>()
                    {
                        EntityName = f2.GetAttributeValue <string>("objecttypecode"),
                        Name       = f2.GetAttributeValue <string>("name"),
                        Right      = f2,
                    });
                }
                mainForm.ProgressPerformStep();
            }



            #endregion
        }
Example #11
0
        public void DiffViews()
        {
            #region Views
            // Instantiate QueryExpression QEsavedquery
            var qe = new QueryExpression("savedquery");
            qe.Criteria.AddCondition(new ConditionExpression("iscustom", ConditionOperator.Equal, true));
            qe.Criteria.AddCondition(new ConditionExpression("iscustomizable", ConditionOperator.Equal, true));
            qe.Criteria.AddCondition(new ConditionExpression("ismanaged", ConditionOperator.Equal, false));
            qe.ColumnSet.AddColumns("name", "querytype", "returnedtypecode", "iscustom");

            var views1 = LeftService.RetrieveMultiple(qe).Entities;
            var views2 = RightService.RetrieveMultiple(qe).Entities;

            List <ComponentDiff <Entity> > viewsDiff = new List <ComponentDiff <Entity> >();
            mainForm.ProgressStart("Views", 1, views1.Count + views2.Count);
            foreach (var v1 in views1)
            {
                var v2 = views2.Where(x => x.GetAttributeValue <string>("name") == v1.GetAttributeValue <string>("name")).FirstOrDefault();
                if (v2 == null)
                {
                    _diffResult.Views.Add(new ComponentDiff <Entity>()
                    {
                        EntityName = v1.GetAttributeValue <string>("returnedtypecode"),
                        Name       = v1.GetAttributeValue <string>("name"),
                        Left       = v1,
                    });
                }
                mainForm.ProgressPerformStep();
            }
            foreach (var v2 in views2)
            {
                var v1 = views1.Where(x => x.GetAttributeValue <string>("name") == v2.GetAttributeValue <string>("name")).FirstOrDefault();
                if (v1 == null)
                {
                    _diffResult.Views.Add(new ComponentDiff <Entity>()
                    {
                        EntityName = v2.GetAttributeValue <string>("returnedtypecode"),
                        Name       = v2.GetAttributeValue <string>("name"),
                        Right      = v2,
                    });
                }
                mainForm.ProgressPerformStep();
            }

            #endregion
        }
Example #12
0
        public void DiffSdkMessageProcessingSteps()
        {
            var qe = new QueryExpression("sdkmessageprocessingstep");

            qe.TopCount = 50;
            qe.ColumnSet.AddColumns("statecode", "name", "sdkmessageid", "ismanaged", "plugintypeid", "sdkmessageprocessingstepid");
            qe.Criteria.AddCondition("ismanaged", ConditionOperator.Equal, false);
            var pluginTypeLink = qe.AddLink("plugintype", "plugintypeid", "plugintypeid");

            pluginTypeLink.EntityAlias = "plugintype";
            pluginTypeLink.Columns.AddColumns("name");


            var smpss1 = LeftService.RetrieveMultiple(qe).Entities;
            var smpss2 = RightService.RetrieveMultiple(qe).Entities;

            mainForm.ProgressStart("Messages Processing Steps", 1, smpss1.Count + smpss2.Count);
            foreach (var smps1 in smpss1)
            {
                var s2 = smpss2.Where(x => x.GetAttributeValue <string>("name") == smps1.GetAttributeValue <string>("name")).FirstOrDefault();
                if (s2 == null)
                {
                    _diffResult.SdkMessageProcessingSteps.Add(new ComponentDiff <Entity>()
                    {
                        Name = smps1.GetAttributeValue <string>("name"),
                        Left = smps1,
                    });
                }
                mainForm.ProgressPerformStep();
            }
            foreach (var smps2 in smpss2)
            {
                var s1 = smpss1.Where(x => x.GetAttributeValue <string>("name") == smps2.GetAttributeValue <string>("name")).FirstOrDefault();
                if (s1 == null)
                {
                    _diffResult.SdkMessageProcessingSteps.Add(new ComponentDiff <Entity>()
                    {
                        Name  = smps2.GetAttributeValue <string>("name"),
                        Right = smps2,
                    });
                }
                mainForm.ProgressPerformStep();
            }
        }
Example #13
0
        public void DiffWorkflows()
        {
            var qe = new QueryExpression("workflow");

            qe.ColumnSet.AddColumns(new string[] { "mode", "primaryentity", "name", "statecode", "type", "uniquename", "category" });
            qe.Criteria.AddCondition("statecode", ConditionOperator.Equal, 1);
            qe.Criteria.AddCondition("type", ConditionOperator.Equal, 1);
            //query.Criteria.AddCondition("category", ConditionOperator.In, 0, 3);

            var wfls1 = LeftService.RetrieveMultiple(qe).Entities;
            var wfls2 = RightService.RetrieveMultiple(qe).Entities;

            mainForm.ProgressStart("Workflows", 1, wfls1.Count + wfls2.Count);

            foreach (var w1 in wfls1)
            {
                var w2 = wfls2.Where(x => x.Id == w1.Id).FirstOrDefault();
                if (w2 == null)
                {
                    _diffResult.Workflows.Add(new ComponentDiff <Entity>()
                    {
                        Name = w1.GetAttributeValue <string>("name"),
                        Left = w1,
                    });
                }
                mainForm.ProgressPerformStep();
            }
            foreach (var w2 in wfls2)
            {
                var w1 = wfls1.Where(x => x.Id == w2.Id).FirstOrDefault();
                if (w1 == null)
                {
                    _diffResult.Workflows.Add(new ComponentDiff <Entity>()
                    {
                        Name  = w2.GetAttributeValue <string>("name"),
                        Right = w2,
                    });
                }
                mainForm.ProgressPerformStep();
            }
        }
Example #14
0
    void InitProfile(HttpContext context)
    {
        try {
            string name = context.Server.UrlDecode(context.Request["name"]);
            string spid = context.Request["spid"];
            string rememberme = context.Request["remember"];
            RightService server = new RightService();
            UserDetail user = server.GetUserDetail(name);
            Employee obj = new Employee {
                Id=System.Guid.NewGuid(),
                Name = name ,
                SpecialtyId = spid ,
                Code = user.EmployeeCode ,
                Roles = { }
            };

            RepositoryFactory<Employees>.Get().Add(obj);
            SetAuthCookie(user.EmployeeCode , rememberme == "1" , context);
        }catch( Exception ex){
            context.Response.Write(ex.Message);
        }
    }
Example #15
0
 public CompositionController(UserManager <User> userManager,
                              DbCompositionService dbCompositionService,
                              DbGenreService dbGenreService,
                              DbTagService dbTagService,
                              ICloudUploader cloudUploader,
                              DbLikeService dbLikeService,
                              DbRatingService dbRatingService,
                              RoleManager <IdentityRole> roleManager,
                              RightService rightService,
                              DbCommentService dbCommentService)
 {
     _userManager          = userManager;
     _dbCompositionService = dbCompositionService;
     _dbGenreService       = dbGenreService;
     _dbTagService         = dbTagService;
     _cloudUploader        = cloudUploader;
     _dbLikeService        = dbLikeService;
     _dbRatingService      = dbRatingService;
     _roleManager          = roleManager;
     _rightService         = rightService;
     _dbCommentService     = dbCommentService;
 }
Example #16
0
        public ServicesManager()
        {
            DataDicInfoService = new DataDicInfoService();
            DataDicTypeService = new DataDicTypeService();
            EmployeeService    = new EmployeeService();
            EquipmentService   = new EquipmentService();


            LoginUserService           = new LoginUserService();
            RightService               = new RightService();
            Role_Right_RelationService = new Role_Right_RelationService();
            RoleService = new RoleService();


            Base_FareService         = new Base_FareService();
            Base_PaymentService      = new Base_PaymentService();
            Base_ProductService      = new Base_ProductService();
            WorkFlow_TempleteService = new WorkFlow_TempleteService();


            Test_Table_TempleteService = new Test_Table_TempleteService();
            Test_TableService          = new Test_TableService();
            Test_Field_TempleteService = new Test_Field_TempleteService();
            Test_FieldService          = new Test_FieldService();

            ProjectService      = new ProjectService();
            AccidentService     = new AccidentService();
            UploadImagesService = new UploadImagesService();

            EmployeeAttendaceService   = new EmployeeAttendaceService();
            EquimentAttendaceService   = new EquimentAttendaceService();
            ExpatriateAttendaceService = new ExpatriateAttendaceService();
            ProjectCostService         = new ProjectCostService();
            CostApplyService           = new CostApplyService();

            AuditService         = new AuditService();
            Role_WorkflowService = new Role_WorkflowService();
        }
Example #17
0
        public void DiffPlugins()
        {
            // Instantiate QueryExpression QEplugintype
            var qe = new QueryExpression("plugintype");

            qe.ColumnSet.AddColumns("friendlyname", "name", "assemblyname", "isworkflowactivity", "plugintypeid", "typename", "plugintypeidunique", "pluginassemblyid");

            var pls1 = LeftService.RetrieveMultiple(qe).Entities;
            var pls2 = RightService.RetrieveMultiple(qe).Entities;

            mainForm.ProgressStart("Plugins", 1, pls1.Count + pls2.Count);
            foreach (var p1 in pls1)
            {
                var p2 = pls2.Where(x => x.GetAttributeValue <string>("name") == p1.GetAttributeValue <string>("name")).FirstOrDefault();
                if (p2 == null)
                {
                    _diffResult.Plugins.Add(new ComponentDiff <Entity>()
                    {
                        Name = p1.GetAttributeValue <string>("name"),
                        Left = p1,
                    });
                }
                mainForm.ProgressPerformStep();
            }
            foreach (var p2 in pls2)
            {
                var p1 = pls1.Where(x => x.GetAttributeValue <string>("name") == p2.GetAttributeValue <string>("name")).FirstOrDefault();
                if (p1 == null)
                {
                    _diffResult.Plugins.Add(new ComponentDiff <Entity>()
                    {
                        Name  = p2.GetAttributeValue <string>("name"),
                        Right = p2,
                    });
                }
                mainForm.ProgressPerformStep();
            }
        }
Example #18
0
        public void DiffRoles()
        {
            // Instantiate QueryExpression QEplugintype
            var qe = new QueryExpression("role");

            qe.ColumnSet.AddColumns("name");

            var roles1 = LeftService.RetrieveMultiple(qe).Entities;
            var roles2 = RightService.RetrieveMultiple(qe).Entities;

            mainForm.ProgressStart("Security Roles", 1, roles1.Count + roles2.Count);
            foreach (var r1 in roles1)
            {
                var r2 = roles2.Where(x => x.Id == r1.Id).FirstOrDefault();
                if (r2 == null)
                {
                    _diffResult.Roles.Add(new ComponentDiff <Entity>()
                    {
                        Name = r1.GetAttributeValue <string>("name"),
                        Left = r1,
                    });
                }
                mainForm.ProgressPerformStep();
            }
            foreach (var r2 in roles2)
            {
                var r1 = roles1.Where(x => x.Id == r2.Id).FirstOrDefault();
                if (r1 == null)
                {
                    _diffResult.Roles.Add(new ComponentDiff <Entity>()
                    {
                        Name  = r2.GetAttributeValue <string>("name"),
                        Right = r2,
                    });
                }
                mainForm.ProgressPerformStep();
            }
        }
Example #19
0
        public void DiffTemapltes(string entityName, List <ComponentDiff <Entity> > diffList, string[] columns, string key)
        {
            var qe = new QueryExpression(entityName);

            qe.ColumnSet.AddColumns(columns);
            qe.Criteria.AddCondition("ismanaged", ConditionOperator.Equal, false);


            var temps1 = LeftService.RetrieveMultiple(qe).Entities;
            var temps2 = RightService.RetrieveMultiple(qe).Entities;

            foreach (var temp1 in temps1)
            {
                var s2 = temps2.Where(x => x.GetAttributeValue <string>(key) == temp1.GetAttributeValue <string>(key)).FirstOrDefault();
                if (s2 == null)
                {
                    diffList.Add(new ComponentDiff <Entity>()
                    {
                        EntityName = entityName,
                        Name       = temp1.GetAttributeValue <string>(key),
                        Left       = temp1,
                    });
                }
            }
            foreach (var temp2 in temps2)
            {
                var s1 = temps1.Where(x => x.GetAttributeValue <string>(key) == temp2.GetAttributeValue <string>(key)).FirstOrDefault();
                if (s1 == null)
                {
                    diffList.Add(new ComponentDiff <Entity>()
                    {
                        EntityName = entityName,
                        Name       = temp2.GetAttributeValue <string>(key),
                        Right      = temp2,
                    });
                }
            }
        }
Example #20
0
        static void Main(string[] args)
        {
            var noInLdapUsers = new List <ShareUserInfo>();
            var noInDbUsers   = new List <ShareUserInfo>();

            using (var dbContext = new DatabaseContext())
            {
                var resources = dbContext.Resources.Where(r => !r.Deleted && r.Description.ToLower().Contains("shar") &&
                                                          r.Description.ToLower().Contains("(") && r.Description.ToLower().Contains(")"))
                                .ToList()
                                .Select(r => new
                {
                    r.IdResource,
                    r.Name,
                    r.Description,
                    Share =
                        r.Description.Substring(r.Description.IndexOf('(') + 1,
                                                r.Description.IndexOf(')') - r.Description.IndexOf('(') - 1)
                }).Where(r => !string.IsNullOrEmpty(r.Share));
                var rightService   = new RightService(new RightRepository(dbContext));
                var ldapRepository = new LdapRepository(ConfigurationManager.AppSettings["ldap_username"],
                                                        ConfigurationManager.AppSettings["ldap_password"]);
                Console.ForegroundColor = ConsoleColor.Green;
                foreach (var resource in resources)
                {
                    Console.WriteLine(@"Processing share {0}", resource.Share);
                    var userResources =
                        rightService.GetResourceRightsOnDate(DateTime.Now.Date, resource.IdResource).GroupBy(r =>
                                                                                                             new
                    {
                        r.IdRequestUser,
                        r.IdResource,
                        r.ResourceName,
                        r.ResourceDescription
                    }).ToList();
                    var ldapUsers = ldapRepository.GetUsersInGroup(ldapRepository.ConvertGroupNameToCn(resource.Share.Split(',')[0].Trim())).ToList();
                    foreach (var userResource in userResources)
                    {
                        var user = dbContext.Users.FirstOrDefault(r => r.IdRequestUser == userResource.Key.IdRequestUser);
                        if (user != null && user.Login != null && !ldapUsers.Any(u =>
                                                                                 string.Equals(u.Login, user.Login, StringComparison.CurrentCultureIgnoreCase)))
                        {
                            Console.WriteLine(@"No user in ldap: {0} ({1}), resource {2}", user.Snp, user.Login, userResource.Key.ResourceName);
                            noInLdapUsers.Add(new ShareUserInfo
                            {
                                Login               = user.Login,
                                Snp                 = user.Snp,
                                ResourceName        = userResource.Key.ResourceName,
                                ResourceDescription = userResource.Key.ResourceDescription
                            });
                        }
                    }
                    foreach (var ldapUser in ldapUsers)
                    {
                        var founded = false;
                        foreach (var userResource in userResources)
                        {
                            var user = dbContext.Users.FirstOrDefault(r => r.IdRequestUser == userResource.Key.IdRequestUser);
                            if (user != null && user.Login != null &&
                                string.Equals(ldapUser.Login, user.Login, StringComparison.CurrentCultureIgnoreCase))
                            {
                                founded = true;
                                break;
                            }
                        }
                        if (!founded)
                        {
                            Console.WriteLine(@"No user in rqrights: {0} ({1}), resource {2}", ldapUser.Snp, ldapUser.Login, resource.Name);
                            noInDbUsers.Add(new ShareUserInfo
                            {
                                Login               = ldapUser.Login,
                                Snp                 = ldapUser.Snp,
                                ResourceName        = resource.Name,
                                ResourceDescription = resource.Description
                            });
                        }
                    }
                }
            }

            SaveStatisticToFile(ConfigurationManager.AppSettings["shares_statistic_file_name"], noInDbUsers, noInLdapUsers);
        }
Example #21
0
 void Validate(HttpContext context)
 {
     try {
         string name = context.Server.UrlDecode(context.Request["name"]);
         string pwd = context.Server.UrlDecode(context.Request["pwd"]);
         string remberme = context.Request["remember"];
         RightService server = new RightService();
         int result = server.Login(name , pwd.GetMD5());
         if (result==0) {
             UserDetail user = server.GetUserDetail(name);
             bool firstLogin = RepositoryFactory<Employees>.Get().ExistsCode(user.EmployeeCode);
             //第一次登录系统
             if (!firstLogin) {
                 result = 4;
             } else {
                 //
                 SetAuthCookie(user.EmployeeCode , remberme == "1" , context);
             }
         }
         context.Response.Write(Helper.LoginResult[result]);
     } catch (Exception ex){
         context.Response.Write(ex.Message);
     }
 }
Example #22
0
 /// <summary>
 /// Receives the RightService via DI.
 /// </summary>
 public RightController(RightService rightService)
 {
     _rightService = rightService;
 }