473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to retrieve user profile property in sharepoint 2010.

1
I have to retrive User Profile Property of logged in User in SharePoint 2010.First I retrieve User's login name then I assign the value to GetUserProfile() method.

Expand|Select|Wrap|Line Numbers
  1. String _AccountName = Microsoft.SharePoint.SPContext.Current.Web.CurrentUser.LoginName;
  2.  
When I did the follows , I got error-"An error was encountered while retrieving the user profile".

Error: UserProfile userProfile = profileManager.GetUserProfile(_AccountName);
Error: UserProfile userProfile = profileManager.GetUserProfile("_AccountName");
Error: UserProfile userProfile = profileManager.GetUserProfile("Doamin\UserName");//[Hardcoded UserLogin Name]

Success: UserProfile userProfile = profileManager.GetUserProfile("Domain\\UserName");
because single '\' wont take.

Now I have to retrive Account Name and assign in
Expand|Select|Wrap|Line Numbers
  1. UserProfile userProfile = profileManager.GetUserProfile(?)
I write the follow



Expand|Select|Wrap|Line Numbers
  1. string[] userDomainName=_AccountName.Split('\\');
  2. string domain = userDomainName[0];
  3. string Name = userDomainName[1];
  4.  
  5. System.Text.StringBuilder sb = new System.Text.StringBuilder();                       
  6. sb.Append(domain);
  7. sb.Apend("\\");
  8. sb.Append("\\");
  9. sb.Append(Name);
  10.  
  11. string DomainUserName = sb.ToString();
  12.  
when I tried with the follow I still gets the error-"An error was encountered while retrieving the user profile".
Error: UserProfile userProfile = profileManager.GetUserProfile(DomainUserName);

Please help me.
Feb 14 '13 #1
1 3567
Rabbit
12,516 Expert Mod 8TB
Try commenting out line 8. There should be no need to use two escaped backslashes.
Feb 14 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Bailey | last post by:
Does not appear to be available in page base classes. I was intending to create a page base class to set the culture based on the profile setting, but the profile property does not apear to be...
3
by: BlueSky | last post by:
Hi, I have to retrieve user information from active directory in ASP.NET by passing Employee ID to it. Can any one give me some information on how I should do this? Thanks!
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
0
by: =?Utf-8?B?Um9iZXJ0byBSYXp6YXV0aQ==?= | last post by:
I've a problem to change a profile property during button click event in a login.aspx page. I try to set profile.property = xxx but after authentication this property remain to defaultvalue by...
0
by: mzmishra | last post by:
Hi, I want to write a client program to retrieve published documents from SharePoint site and store on the users machine. Can some body help me on this
4
by: Scott M. | last post by:
When profile data is stored in ASP .NET, where is the user data persisted? For how long is it persisted: is it session persisted or permanent (like a cookie)?
5
by: geoffreyfishing | last post by:
I have tried posting everywhere, but no one has given me an answer so far. I am willing to try everything short of a clean install of vista. My Problem: Some process has a locking handle on the...
0
hemantbasva
by: hemantbasva | last post by:
As per my knowledge, contacts data are available in names.nsf. There are two names.nsf 1) server based for global contact 2) local based for personal contact I have assigned to migrate the data...
2
hemantbasva
by: hemantbasva | last post by:
I have created a custom timer job using Visual Studio 2010 ultimate and have deployed the same in Sharepoint 2010 environment. The timer job is deployed successfully but the problem is it not...
0
by: napstar | last post by:
I have custom asset application done in ASP.NET.How do I add this app 2/have it run in Sharepoint 2010 ?.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.