# Error while adding user to SharePoint group using CSOM

I'm facing error while trying to add users into the SharePoint groups using CSOM. When I try to add user by passing user name as "domain\V*****" (all users start with "v" character), it through error as "\v" is hexadecimal value which can't pass.

Also I tried again by adding escape character like @domain\v******, but no luck..

But I tried the code with some test users like "domain\user1" which is working fine.

Any help would be appreciated..

• Are you trying to add all users under the domain? You can't pass wild card characters – Amal Hashim May 2 '16 at 14:55
• @AmalHashim No, I'm trying to add single user only.. All username starts with V***** like ID.. – Arun May 2 '16 at 15:34
• Can you post code you tried? – Amal Hashim May 2 '16 at 15:35
• should be @"domain\victor" or "domain\\victor" with two slashes – Mike May 2 '16 at 20:37

I use the code bellow, but like Mike said maybe the key is to provide the string like "domain\user":

UserCreationInformation uci = new UserCreationInformation();
uci.Title = "John Lennon";
uci.Email = "jlennon@thebeatles.com";

Web web = ctx.Web;
GroupCollection groupcoll = web.SiteGroups;
string grouptitle = "My Group";
ctx.Load(groupcoll, grps => grps.Include(g => g.Title).Where(g => g.Title == grouptitle));
ctx.ExecuteQuery();
Group group = null;

User member = web.EnsureUser(uci.Email);