SharePoint learning notes-error handling-the user does not exist or is not unique.

Source: Internet
Author: User

Many people have encountered similar errors on the Internet, and there are also many reasons for such errors, this error occurs when I try to add a user to a specified group through the ecmascript object model.

Problem 1. When I try to add a user to a specified group in SharePoint and the user already exists in site collection, I get this error message in this context.
Problem 2. If I try to add a user that does not exist in site collection to a specified group in SharePoint in AD, this operation cannot be successful. Because Microsoft's msdn clearly states that only ad users that already exist in the site collection can be added.
My solutions are as follows:
1. Check the information about user settingsCodeWhether the problem exists.
My original code is as follows:

Function Addusertosharepointgroup (groupid ){

// VaR clientcontext = new sp. clientcontext (siteurl );
VaR Clientcontext = New Sp. clientcontext. get_current ();
VaR Collgroup = clientcontext. get_web (). get_sitegroups ();
VaR Ogroup = collgroup. getbyid (groupid );
VaR Usercreationinfo =New Sp. usercreationinformation ();
Usercreationinfo. set_email ('help @ star.com.cn ');
Usercreationinfo. set_loginname ('help ');
Usercreationinfo. set_title ('help ');
This . Ouser = ogroup. get_users (). Add (usercreationinfo ); // Add User into group

VaR Userinfo = '\ nuser:' + ouser. get_title () +
'\ Nemail:' + ouser. get_email () +
'\ Nlogin name:' + ouser. get_loginname ();

Alert (userinfo );
Clientcontext. Load (ouser );
Clientcontext.exe cutequeryasync (function. createdelegate (This,This. Onquerysucceededaddusertow.pointgroup ),
Function. createdelegate (This,This. Onqueryfailedaddusertow.pointgroup ));
}

FunctionOnquerysucceededaddusertow.pointgroup (){

Alert (This. Ouser. get_title () + "added .");
}

FunctionOnqueryfailedaddusertow.pointgroup (sender, argS ){

Alert ('request failed. '+ args. get_message () +' \ n' + args. get_stacktrace ());
}

This code has problems mainly in the usercreateinfo code:

1. The set_loginname setting item should be added to the domain where the user is located
2. domain should be followed by "\". Otherwise, the domain will be directly connected to the user (for example, domainuser) during the actual user generation ), of course, such users do not exist in AD.
Therefore, in code settings, the information for the user should meet the actual setting of the user in the ad account, therefore, in the above code, you can see that I have added an alert to display the set information, so that you can compare it with the corresponding information of the user in AD when querying the error.

The modified code for the above problem is as follows:

Function Addusertosharepointgroup (groupid ){

// VaR clientcontext = new sp. clientcontext (siteurl );
VaR Clientcontext = New Sp. clientcontext. get_current ();
VaR Collgroup = clientcontext. get_web (). get_sitegroups ();
VaR Ogroup = collgroup. getbyid (groupid );
VaR Usercreationinfo = New Sp. usercreationinformation ();
Usercreationinfo. set_email ('help @ star.com.cn ');
Usercreationinfo. set_loginname ('Star \ help ');
Usercreationinfo. set_title ('help ');
This . Ouser = ogroup. get_users (). Add (usercreationinfo ); // Add User into group

VaR Userinfo = '\ nuser:' + ouser. get_title () +
'\ Nemail:' + ouser. get_email () +
'\ Nlogin name:' + ouser. get_loginname ();

Alert (userinfo );
Clientcontext. Load (ouser );
Clientcontext.exe cutequeryasync (function. createdelegate (This,This. Onquerysucceededaddusertow.pointgroup ),
Function. createdelegate (This,This. Onqueryfailedaddusertow.pointgroup ));
}

FunctionOnquerysucceededaddusertow.pointgroup (){

Alert (This. Ouser. get_title () + "added .");
}

FunctionOnqueryfailedaddusertow.pointgroup (sender, argS ){

Alert ('request failed. '+ args. get_message () +' \ n' + args. get_stacktrace ());
}

 

 2. Check the Domain member: Digitally encrypt or sign secure channel data (always) Security Settings of Windows server.
If the preceding troubleshooting does not solve the user does not exist or is not unique error, go to this step and try again.

Because my development environment is Server 2008 R2, Kerberos is used for authentication (it is said that this is very important, because if Windows NTLM is used, there will be no information communication problem between the application and the ad Environment). It is said that a feature in Windows Server 2008 (or R2) does not support applications running on SharePoint, this may cause ad information exchange problems.
The solution is to set the security item Domain member: Digitally encrypt or sign secure channel data (always. This option is enabled by default. We need to manually stop it. The method is to start-> Run-> type gpedit. MSC on the server.
After setting the interface, open it in sequence
Computer Configuration-> Windows Settings-> Security Settings-> Local Policies-> Security Options. You can see this option on the right of security options. Please stop it manually and then restart the server.

 

It must be noted that here I only list the above two solutions. If the above situations do not solve your problem, you need to address your specific situation, capture possible error messages to solve the problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.