无法访问自定义用户个人资料属性 [英] Unable to access custom user profile preperty

查看:61
本文介绍了无法访问自定义用户个人资料属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经创建了一个自定义用户配置文件属性"TrainingSingleValue",具有以下选项- 

 

我可以在用户个人资料属性部分看到该属性.

现在,当我尝试访问此属性时,现在都在som代码中,但出现以下错误-

{未定义属性:TrainingSingleValue".管理员必须在个人档案管理"工具中创建此属性."}

这是我用来访问此属性的代码-

SPServiceContext serviceContext = SPServiceContext.GetContext(site);
  Console.WriteLine(检索用户个人资料:");
  UserProfileManager userProfileMgr =新的UserProfileManager(serviceContext);

                                UserProfile用户= userProfileMgr.GetUserProfile(fieldValue.User.LoginName);
                                user ["TrainingSingleValue"].Value ="Mohit";

我正在服务帐户下运行代码.任何帮助将不胜感激.

预先感谢


K Mohit

解决方案

Hi K Mohit,

您需要首先查看"TrainingSingleValue"已在您的默认用户个人资料中创建.

请参阅以下网址的陈子洲爷的答复:


Hi All,

I have created a custom user profile property "TrainingSingleValue" with below options - 

 

I can see the property in the user profile property section.

Now in som code whenever I am trying to access this property I am getting below error- 

{"Property Not Defined: TrainingSingleValue.  An administrator must create this property in the Profile Administration tool."}

Here is the code that I am using to access this property - 

 SPServiceContext serviceContext = SPServiceContext.GetContext(site);
 Console.WriteLine("Retrieving user profiles:");
 UserProfileManager userProfileMgr = new UserProfileManager(serviceContext);

                                UserProfile user = userProfileMgr.GetUserProfile(fieldValue.User.LoginName);
                                user["TrainingSingleValue"].Value = "Mohit";

I am running the code under service account. Any help would be appreciates.

Thanks in advance


K Mohit

解决方案

Hi K Mohit,

You need first to check out the "TrainingSingleValue" has been created in your default user profile.

Please refer to Zizhouye Chen's reply at:

https://social.technet.microsoft.com/Forums/office/en-US/d183d133-7fdd-4053-a2ef-dd09b892bf33/error-when-i-get-the-custom-property-an-administrator-must-create-this-property-in-the-profile?forum=sharepointdevelopmentprevious

Best regards,

Lee Liu


这篇关于无法访问自定义用户个人资料属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆