Create user and assign it to role/group
This examples show how you can create user and how to assign user to groups or roles.
Create user
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;
namespace DocuWare.PlatformClientExamples
{
static partial class Examples
{
public static User CreateUser(Organization org, string userName)
{
NewUser createUser = new NewUser();
createUser.DbName = userName;
createUser.Name = userName;
createUser.Email = string.Format("email{0}@tstes.st", createUser.DbName);
createUser.NetworkId = "";
createUser.Password = "password";
return org.PostToUserInfoRelationForUser(createUser);
}
}
}
Add/remove user to role
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;
namespace DocuWare.PlatformClientExamples
{
static partial class Examples
{
public static void AssignUserToRole(User user, Role role)
{
//Add user to the role
user.PutToRolesRelationForString(new AssignmentOperation { OperationType = AssignmentOperationType.Add, Ids = new List<string>() { role.Id } });
//Remove user form the role
user.PutToRolesRelationForString(new AssignmentOperation { OperationType = AssignmentOperationType.Remove, Ids = new List<string>() { role.Id } });
}
}
}
Add/remove user to group
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DocuWare.Platform.ServerClient;
namespace DocuWare.PlatformClientExamples
{
static partial class Examples
{
public static void AssignUserToGroup(User user, Group group)
{
//Add user to the group
user.PutToGroupsRelationForString(new AssignmentOperation { OperationType = AssignmentOperationType.Add, Ids = new List<string>() { group.Id } });
//Remove user form the group
user.PutToGroupsRelationForString(new AssignmentOperation { OperationType = AssignmentOperationType.Remove, Ids = new List<string>() { group.Id } });
}
}
}