2

I am getting an error when trying to add a user to group in JavaScript, here is my code below:

    user = web.ensureUser("domain\\natalie");
    membersGroup = web.get_siteGroups().getByName("site Members");
    membersGroup.get_users().add(user);
    userCollection = membersGroup.get_users();

    context.load(user);
    context.load(membersGroup);
    context.load(userCollection);
    context.executeQueryAsync(_onUserSucceed, _onFail);

I am getting the error: The parameter loginName cannot be empty or bigger than 251 characters.

1 Answer 1

2

Your code seems fine, but how did you put the domain name? Was it domain\natalie? Sometimes you need to make it like: domain.local to make it work or domain.[value] depending on your environment. The thing is that you have to fully qualify it when it's needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.