首页 > 代码库 > crm SDK 设置用户的上级
crm SDK 设置用户的上级
/// <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 从旧系统重新迁移到新系统.
以上代码可以随便放在一个plugin里执行就行了.
引自:http://blog.csdn.net/y_f123/article/details/37870313
/// <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 SDK 设置用户的上级
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。