So I am working on understanding DDD better and there is the concept of aggregate roots. What I am trying to understand is at what point is it ok to modify the child "relationships"?

EG (Simple example at that):

Code:
public class User
{
   public string Id { get; private set; }
   public string Name { get; set; }
   public string Username {get; set;}
   public List<string> RoleIds {get; private set; }

   //......

   public bool AddUserToRole(Role role)
   {
      RoleIds.Add(role.Id);
      //Save updated user and role relationship to the database
   }
}



public class Role
{
   public string Id { get;  private set; }
   public string Name { get; set; }
   public string Description { get; set; }
}
With the above example, is how I have adding the role to the user correct? Since you have to use the method of the aggregate root in order to add the role to the user and not accessing the child aggregate directly.