码迷,mamicode.com
首页 > 其他好文 > 详细

crm设置用户上级和业务部门

时间:2014-07-16 14:43:52      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:crm设置用户上级和业务部门   crm删除用户的上级   crm设置用户的业务部门   crm设置用户的上级   

        /// <summary>
        /// 删除用户的上级
        /// </summary>
        public void RemoveParent(IOrganizationService service,Guid userId)
        {
            RemoveParentRequest removeRequest = new RemoveParentRequest();
            removeRequest.Target = new EntityReference() { LogicalName = "systemuser", Id = userId };
            service.Execute(removeRequest);
        }

        /// <summary>
        /// 设置用户的业务部门
        /// </summary>
        /// <param name="service">服务</param>
        /// <param name="userId">用户Id</param>
        /// <param name="businessId">部门Id</param>
        public void SetUserBusiness(IOrganizationService service, Guid userId,Guid businessId)
        {
            //更改用户的业务部门,会重置角色
            SetBusinessSystemUserRequest request = new SetBusinessSystemUserRequest();
            request.BusinessId = businessId;
            request.UserId = userId;
            //安全角色
            request.ReassignPrincipal = new EntityReference() { LogicalName = "role",Id = Guid.NewGuid() };
            service.Execute(request);
        }

        /// <summary>
        /// 设置用户的上级
        /// </summary>
        /// <param name="service">服务</param>
        /// <param name="userId">用户</param>
        /// <param name="parentId">上级</param>
        public void SetUserParent(IOrganizationService service,Guid userId,Guid parentId)
        {
            SetParentSystemUserRequest request = new SetParentSystemUserRequest();
            //当前用户
            request.UserId = userId;
            //上级
            request.ParentId = parentId;
            //是否保存子用户
            request.KeepChildUsers = true;

            service.Execute(request);
        }

crm设置用户上级和业务部门,布布扣,bubuko.com

crm设置用户上级和业务部门

标签:crm设置用户上级和业务部门   crm删除用户的上级   crm设置用户的业务部门   crm设置用户的上级   

原文地址:http://blog.csdn.net/y_f123/article/details/37870313

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!