.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Get Sharepoint user profile information of all properties in JavaScript

Posted By:Sagar Pardeshi       Posted Date: March 17, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

Get Sharepoint user profile information of all properties in JavaScript
 

Introduction

In this article we need to pass the user profile information let's say Account Name , First Name, Last Name, PictureUrl and SPS-SipAddress..etc to the some other function in JAVA SCRIPT. For accessing current logged in user information you need to call GetUserProfileByName function of userprofileservice web service.  
I have written a JavaScript code for accessing the GetUserProfileByName function of userprofileservice web service:

function fetchUserProfileData() {

            var art = null;

            //IE

            if (window.ActiveXObject) {

                art = new ActiveXObject("Microsoft.XMLHTTP");

            }//Mozilla, chrome, etc.,

            else if (window.XMLHttpRequest) {

                art = new XMLHttpRequest();

            }

            else {

                throw new Error("XMLHttpRequest not supported");

            }

            if (art == null) return null;

            art.Open("POST", _spPageContextInfo.webAbsoluteUrl+ "/_vti_bin/userprofileservice.asmx", false);

            art.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

            art.setRequestHeader("SOAPAction", "http://microsoft.com/webservices/SharePointPortalServer/UserProfileService/GetUserProfileByName");

 

            var Xsoap = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://schemas.microsoft.com/sharepoint/soap/\"><soap:Body><GetUserProfileByName xmlns=\"http://microsoft.com/webservices/SharePointPortalServer/UserProfileService\"><AccountName>Domain\\UserName</AccountName></GetUserProfileByName></soap:Body></soap:Envelope>";

            art.Send(Xsoap);

            var xmlDoc = art.responseXML;

alert(xmlDoc);

            var strAccountSPSHireDate = "";

          

var elmValue = xmlDoc.getElementsByTagName("Value");

            for (i = 0; i < elmValue.length; i++) {

                if (elmValue[i].parentNode.parentNode.parentNode.childNodes[2].text =='SPS-HireDate

') {

                    strAccountSPSHireDate = elmValue[i].childNodes[0].nodeValue;

                }

}

alert(strAccountSPSHireDate);

            }

        </script>

List of User Properties :

AccountName 
DirectReports 
DisplayName 
Email 
ExtendedManagers 
ExtendedReports 
IsFollowed 
LatestPost 
Peers 
PersonalUrl 
PictureUrl" 
Title 
UserProfileProperties 
UserUrl

List of User Profile Properties :

AboutMe

SPS-LastKeywordAdded

AccountName

SPS-Locale

ADGuid

SPS-Location

Assistant

SPS-MasterAccountName

CellPhone

SPS-MemberOf

Department

SPS-MUILanguages

EduExternalSyncState

SPS-MySiteUpgrade

EduOAuthTokenProviders

SPS-O15FirstRunExperience

EduPersonalSiteState

SPS-ObjectExists

EduUserRole

SPS-OWAUrl

Fax

SPS-PastProjects

FirstName

SPS-Peers

HomePhone

SPS-PersonalSiteCapabilities

LastName

SPS-PersonalSiteInstantiationState

Manager

SPS-PhoneticDisplayName

Office

SPS-PhoneticFirstName

PersonalSpace

SPS-PhoneticLastName

PictureURL

SPS-PrivacyActivity

PreferredName

SPS-PrivacyPeople

PublicSiteRedirect

SPS-ProxyAddresses

QuickLinks

SPS-RegionalSettings-FollowWeb

SID

SPS-RegionalSettings-Initialized

SISUserId

SPS-ResourceAccountName

SPS-AdjustHijriDays

SPS-ResourceSID

SPS-AltCalendarType

SPS-Responsibility

SPS-Birthday

SPS-SavedAccountName

SPS-CalendarType

SPS-SavedSID

SPS-ClaimID

SPS-School

SPS-ClaimProviderID

SPS-ShowWeeks

SPS-ClaimProviderType

SPS-SipAddress

SPS-ContentLanguages

SPS-Skills

SPS-DataSource

SPS-SourceObjectDN

SPS-Department

SPS-StatusNotes

SPS-DisplayOrder

SPS-Time24

SPS-DistinguishedName

SPS-TimeZone

SPS-DontSuggestList

SPS-UserPrincipalName

SPS-Dotted-line

SPS-WorkDayEndHour

SPS-EmailOptin

SPS-WorkDayStartHour

SPS-FeedIdentifier

SPS-WorkDays

SPS-FirstDayOfWeek

Title

SPS-FirstWeekOfYear

UserName

SPS-HashTags

UserProfile_GUID

SPS-HireDate

WebSite

SPS-Interests

WorkEmail

SPS-JobTitle

WorkPhone

SPS-LastColleagueAdded

 




 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend