Classical hair in string theory I: general formulation