/// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The Dfa user object running the code example.
        /// </param>
        public override void Run(DfaUser user)
        {
            // Create UserRoleRemoteService instance.
              UserRoleRemoteService service = (UserRoleRemoteService) user.GetService(
              DfaService.v1_19.UserRoleRemoteService);

              String userRoleName = _T("INSERT_USER_ROLE_NAME_HERE");
              long subnetworkId = long.Parse(_T("INSERT_SUBNETWORK_ID_HERE"));
              long parentUserRoleId = long.Parse(_T("INSERT_PARENT_USER_ROLE_ID_HERE"));
              long permission1Id = long.Parse(_T("INSERT_FIRST_PERMISSION_ID_HERE"));
              long permission2Id = long.Parse(_T("INSERT_SECOND_PERMISSION_ID_HERE"));

              // Create user role structure.
              UserRole userRole = new UserRole();
              userRole.id = 0;
              userRole.name = userRoleName;
              userRole.subnetworkId = subnetworkId;
              userRole.parentUserRoleId = parentUserRoleId;

              // Create a permission object to represent each permission this user role
              // has.
              Permission permission1 = new Permission();
              permission1.id = permission1Id;
              Permission permission2 = new Permission();
              permission2.id = permission2Id;

              // Add the permissions to the user role.
              userRole.permissions = new Permission[] {permission1, permission2};

              try {
            // Create user role.
            UserRoleSaveResult userRoleResult = service.saveUserRole(userRole);

            if (userRoleResult != null) {
              // Display user role id.
              Console.WriteLine("User role with id \"{0} was created.", userRoleResult.id);
            }
              } catch (Exception e) {
            Console.WriteLine("Failed to create user role. Exception says \"{0}\"", e.Message);
              }
        }
示例#2
0
 public UserRoleSaveResult saveUserRole(UserRole userGroup) {
   object[] results = this.Invoke("saveUserRole", new object[] {userGroup});
   return ((UserRoleSaveResult) (results[0]));
 }