Hello All,
In a follwing post we will see how to read User Profile Property values Programmatically.
In a below code snippet ,I am reading Birthday and Anniversary Custom Properties and some other Property values and updating in SharePoint List.
These values are reading for all the Users.
}
}
});
In a follwing post we will see how to read User Profile Property values Programmatically.
In a below code snippet ,I am reading Birthday and Anniversary Custom Properties and some other Property values and updating in SharePoint List.
These values are reading for all the Users.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSite = new SPSite(siteurl))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPServiceContext
serverContext = SPServiceContext.GetContext(oSite);
UserProfileManager
userProfileMangager = new UserProfileManager(serverContext);
IEnumerator profileEnumerator = userProfileMangager.GetEnumerator();
while (profileEnumerator.MoveNext())
{
string strBDate = string.Empty;
string strADate = string.Empty;
DateTime bDate;
DateTime aDate;
UserProfile
profile = profileEnumerator.Current as UserProfile;
//// Gets the Birthday Value.
////Birthday is the custom Property in my case
////Birthday is the custom Property in my case
if (!string.IsNullOrEmpty(
Convert.ToString(profile["Birthday"].Value)))
Convert.ToString(profile["Birthday"].Value)))
{
bDate = Convert.ToDateTime(profile["Birthday"].Value);
strBDate =
bDate.ToString("m");
}
//// Gets the Anniversary Value.
////Anniversary is the Custom Property in my case
////Anniversary is the Custom Property in my case
if (!string.IsNullOrEmpty(
Convert.ToString(profile["Anniversary"].Value)))
Convert.ToString(profile["Anniversary"].Value)))
{
aDate = Convert.ToDateTime(profile["Anniversary"].Value);
strADate =
aDate.ToString("m");
}
////Reading Picture Value
////Reading Picture Value
if (!string.IsNullOrEmpty(
Convert.ToString(profile["PictureURL"].Value)))
Convert.ToString(profile["PictureURL"].Value)))
{
oListItem["ProfilePic"] = Convert.ToString(profile["PictureURL"].Value);
}
//// Reading Department Value
//// Reading Department Value
oListItem["Department"]
=
Convert.ToString(profile["Department"].Value);
Convert.ToString(profile["Department"].Value);
//// Reading Designation Value
oListItem["Designation"]
=
Convert.ToString(profile["Title"].Value);
Convert.ToString(profile["Title"].Value);
SPUser user = oWeb.EnsureUser(Convert.ToString(profile.DisplayName));
}}
}
});
Related Post
SharePoint
- Build Automation (CICD) of WebJob in SharePoint Online
- List view render using JSLink with Fabric UI
- Delete Quick Links using Powershell
- SharePoint Interview Questions and Answers..
- Issues:SharePoint Foundation 2013 Prerequisites installation(off line) on Windows Server2012 R2
- SharePoint Column Field Types
- Alternate to InfoPath Forms in SharePoint
- Get the Items inside the Folder in document Library in SharePoint 2013 using REST API
- SharePoint 2016 [Beta] Release Date
- SharePoint Modal Dailoge to Open Page
- What is Look up Column and how to use in SharePoint 2010,2013
- People Picker Check User Entry and Resolve
- How to Get User Data from AD (Active Directory) in SharePoint Using C#
- History of SHAREpoINt
- How to Create Application Page in SharePoint using Visual Studio 2010,2013
- Retrieve Site Features in SharePoint
- Weather Webpart by using Yahoo Service in Share Point
- Activate Telnet Client in Windows Server
- Navigate to another Page After Clicking on JavaScript Alert
- How to read List Item Version Collection Programmatically
- How to get Worker Process from Command Prompt
- How to Use DataTable.js in SharePoint webpart
- Adding New Link to PromotedActions Delegate Control in SharePoint 2013
- How to Deploy Master Page in Share Point
- Get Role Definition in SharePoint
SharePoint 2010
- List view render using JSLink with Fabric UI
- Delete Quick Links using Powershell
- delete/Add Top Navigation Links using Powershell
- PowerShell::Get Content Database Size in SharePoint
- PowerShell :: Delete All List Items
- Basics: Difference between Synchronous Events and Asynchronous Events in SharePoint
- Remove-SPSite 0x80070003 - Forcely delete Site Collection that cannot be deleted
- This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.
- Restore-SPSite: The operation that you are attempting to perform cannot be completed successfully.
- Get List Field Type using ECMA Script in SP Hosted Apps
- SharePoint Interview Questions and Answers..
- What are Event Receivers and How to Create Sample event Receivers and attach to List/ Doc Library ?
- Export SharePoint Search Crawl log to CSV File.
- Create Content Type using ECMA Script
- Get List Content Types using ECMA Script
- SharePoint Modal Dailoge to Open Page
- SPDataSource in SharePoint.
- Capacity planning and Sizing in SharePoint 2010
- Enable 'Save site as Template' in Publishing Sites by using SharePoint Designer
- Read Enhanced Rich Text Values in SharePoint
- What is Web part life Cycle in SharePoint 2013 and SharePoint 2010
- How to Hide Controls in SharePoint New Form Based on User using ECMA Script.
- What is the Content Type for Custom List in SharePoint 2013, SharePoint 2010
- What is calculated column in SharePoint 2013 ,2010
- Create Meetings by using Exchange Server API
gud
ReplyDelete