Question: I'm trying to Add a User to the SharePoint site using CSOM but I'm getting an stating 'The user does not exist or is not unique' is there something wrong with my LoginName?. "anil@developer19.onmicrosoft.com" is an active user in the Organization.

```
using System;
using System.Security;
using Microsoft.Online.SharePoint.TenantAdministration;
using Microsoft.SharePoint.Client;
namespace CreateSiteCollections
{
    class Program
    {
        static void Main(string[] args)
        {
           //Opens the Admin URL 
            using (ClientContext ctx1 = new ClientContext("https://developer19.sharepoint.com/sites/codesite"))
            {
                //Authenticating with Tenant Admin
                SecureString passWord = new SecureString();
                foreach (char c in "Password".ToCharArray())
                    passWord.AppendChar(c);
                ctx1.Credentials = new SharePointOnlineCredentials("kailash@developer19.onmicrosoft.com", passWord);
                        GroupCollection cg = ctx1.Web.SiteGroups;
                        Group oGroup = cg.GetById(14);

                        UserCreationInformation user = new UserCreationInformation();
                        user.Email = "anil@developer19.onmicrosoft.com";
                        user.LoginName = "developer19/anil";
                        user.Title = "Anil";
                        User oUser = oGroup.Users.Add(user);
                        ctx1.ExecuteQuery();
            }
      }
   }
}

```

Answer: 
Instead trying of these whole steps I've learnt other way to do this on <http://www.codesharepoint.com/csom/add-user-to-site-group-in-sharepoint-using-csom> . But you can use both GetByName or GetById.

```
Group oGroup = ctx.Web.SiteGroups.GetByName("NewCSOM Group");
                User oUser = ctx.Web.EnsureUser("anil@developer19.onmicrosoft.com");
                oGroup.Users.AddUser(oUser);
                ctx.ExecuteQuery();

```
The login name of a user can be checked with Rest API:

siteurl/\_api/web/siteusers

[![enter image description here](https://i.stack.imgur.com/TK1Ib.png)](https://i.stack.imgur.com/TK1Ib.png)

So for UserCreationInformation class, update the valid login name will be working:

[![enter image description here](https://i.stack.imgur.com/ImjoP.png)](https://i.stack.imgur.com/ImjoP.png)