Sharepoint学习笔记—error处理-- The user does not exist or is not unique.
2012-08-02 05:32
531 查看
看到网上不少人遇到过这种类似的错误,而产生这种错误的原因也有多种,我产生此错误的背景是在试图通过ECMAscript对象模型把一个User添加到某个指定的Group中时遇到的。
问题1.当我试图把一个User添加到Sharepoint的某个指定的Group,而这个User已经在Site Collection中存在,在此背景下我得到此错误信息。
问题2.如果我试图把一个在Site Collection中不存在,而在AD中存在的User添加到Sharepoint的某个指定Group中时,这种操作是肯定不能成功的。因为微软的MSDN中明确指出了只能添加已经在Site Collection中存在的AD Users。
我的解决步骤如下:
一、检查关于用户设置信息的代码是否有问题。
我原来的代码如下:
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.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededaddUserToSharePointGroup),
Function.createDelegate(this, this.onQueryFailedaddUserToSharePointGroup));
}
function onQuerySucceededaddUserToSharePointGroup() {
alert(this.oUser.get_title() + " added.");
}
function onQueryFailedaddUserToSharePointGroup(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
} 此代码存在问题主要在userCreateInfo代码:
1、set_loginName设置项应该加入此用户所在的域 DOMAIN
2、DOMAIN后面应该用"\\",否则在实际生成的User时就会把DOMAIN与User直接连接起来(如:DOMAINuser),这样的用户当然在AD中是不存在的
因此,在代码设置中,针对User的Information应该符合真正存在的那个User在AD Account中的设置情况,所以在上述代码中你可以看到我加入了一个alert来显示设置的信息,便于你在查错时与AD中此user的对应信息进行比较。
针对上面的问题修改后的代码如下:
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.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededaddUserToSharePointGroup),
Function.createDelegate(this, this.onQueryFailedaddUserToSharePointGroup));
}
function onQuerySucceededaddUserToSharePointGroup() {
alert(this.oUser.get_title() + " added.");
}
function onQueryFailedaddUserToSharePointGroup(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
二、检查Windows Server的 Domain member: Digitally encrypt or sign secure channel data (always) 安全设置项。
如果上面的排错没有解决The user does not exist or is not unique报错,那么就进入这一步进行偿试。
由于我的开发环境是Server 2008 R2,认证方式采用的是Kerberos(据说这点很重要,因为如果采用的是windows NTLM方式,则不会存在Application与AD环境的信息沟通问题),据说Windows Server 2008 (或 R2)中有某个Feature不支持Sharepoint上运行的Application,由此可能会造成AD信息交换出问题。
解决的办法就是设置Domain member: Digitally encrypt or sign secure channel data (always) 这个安全项。这个选项默认是开启的,我们需要手工停止它。方法是在服务器上 Start -> Run -> type gpedit.msc.
进行设置界面后,依序打开
Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options.在Security Options的右边你可以看到此选项,请手工将其停止,然后重启服务器。
需要指明的是,此处我只列出了上述两种解决思路,如果上面的情况均未解决你遇到的问题,你就需要针对你自己的特定情况,捕获可能的相关错误信息来解决问题。
问题1.当我试图把一个User添加到Sharepoint的某个指定的Group,而这个User已经在Site Collection中存在,在此背景下我得到此错误信息。
问题2.如果我试图把一个在Site Collection中不存在,而在AD中存在的User添加到Sharepoint的某个指定Group中时,这种操作是肯定不能成功的。因为微软的MSDN中明确指出了只能添加已经在Site Collection中存在的AD Users。
我的解决步骤如下:
一、检查关于用户设置信息的代码是否有问题。
我原来的代码如下:
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.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededaddUserToSharePointGroup),
Function.createDelegate(this, this.onQueryFailedaddUserToSharePointGroup));
}
function onQuerySucceededaddUserToSharePointGroup() {
alert(this.oUser.get_title() + " added.");
}
function onQueryFailedaddUserToSharePointGroup(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
} 此代码存在问题主要在userCreateInfo代码:
1、set_loginName设置项应该加入此用户所在的域 DOMAIN
2、DOMAIN后面应该用"\\",否则在实际生成的User时就会把DOMAIN与User直接连接起来(如:DOMAINuser),这样的用户当然在AD中是不存在的
因此,在代码设置中,针对User的Information应该符合真正存在的那个User在AD Account中的设置情况,所以在上述代码中你可以看到我加入了一个alert来显示设置的信息,便于你在查错时与AD中此user的对应信息进行比较。
针对上面的问题修改后的代码如下:
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.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededaddUserToSharePointGroup),
Function.createDelegate(this, this.onQueryFailedaddUserToSharePointGroup));
}
function onQuerySucceededaddUserToSharePointGroup() {
alert(this.oUser.get_title() + " added.");
}
function onQueryFailedaddUserToSharePointGroup(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
二、检查Windows Server的 Domain member: Digitally encrypt or sign secure channel data (always) 安全设置项。
如果上面的排错没有解决The user does not exist or is not unique报错,那么就进入这一步进行偿试。
由于我的开发环境是Server 2008 R2,认证方式采用的是Kerberos(据说这点很重要,因为如果采用的是windows NTLM方式,则不会存在Application与AD环境的信息沟通问题),据说Windows Server 2008 (或 R2)中有某个Feature不支持Sharepoint上运行的Application,由此可能会造成AD信息交换出问题。
解决的办法就是设置Domain member: Digitally encrypt or sign secure channel data (always) 这个安全项。这个选项默认是开启的,我们需要手工停止它。方法是在服务器上 Start -> Run -> type gpedit.msc.
进行设置界面后,依序打开
Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options.在Security Options的右边你可以看到此选项,请手工将其停止,然后重启服务器。
需要指明的是,此处我只列出了上述两种解决思路,如果上面的情况均未解决你遇到的问题,你就需要针对你自己的特定情况,捕获可能的相关错误信息来解决问题。
相关文章推荐
- The user does not exist or is not unique错误
- ERROR 1449 (HY000): The user specified as a definer ('admin_isbox'@'%') does not exist-j解决方案
- About Derby "ERROR 42X51: The class '***' does not exist or is inaccessible. This can hap pen if the class is not public."
- Error starting the test run: Build directory of the test run is not specified or does not exist
- 关于“error C2871: 'std' : does not exist or is not a namespace”和“Error spawning cl.exe“的解决办法
- [ERROR] Error executing Maven. [ERROR] The specified user settings file does not exist: E:\apache-ma
- GP服务扩展模块错误the tool is not licensed,Dataset GPL0 does not exist or is not support解决方案
- Got error: 1449: The user specified as a definer ('root'@'%') does not exist
- RPC Fault faultString="[MessagingError message='Destination 'data-push' either does not exist or the destination has no channels
- If the job does not exist, an error from msdb.dbo.sp_delete_job is expected
- ERROR 1449 (HY000): The user specified as a definer ('root'@'%') does not exist
- ERROR 1449 (HY000): The user specified as a definer ('db'@'%') does not exist
- If the job does not exist, an error from msdb.dbo.sp_delete_job is expected
- [Err] 1449 - The user specified as a definer ('admin_isbox'@'localhost') does not exist
- ASP.NET Error: Keyset does not exist or Access is denied.
- mysqld_safe启动报错 mysqld_safe The file /usr/local/mysql/bin/mysqld does not exist or is not executable
- ECM: The inventory location file for the special Windows NT case does not exist or is unreadable
- Centos下_MysqL5.7在使用mysqldump命令备份数据库报错:mysqldump: Got error: 1449: The user specified as a definer ('fk_system'@'localhost') does not exist when using LOCK TABLES
- 关于error C2871: ''std'' : does not exist or is not a namespace处理
- 解决和说明> eth.getCompilers() Error: The method eth_getCompilers does not exist/is not available