I am having SharePoint 2013 Foundation. I want to retrieve current logged-in user's profile properties from AD. As there is no User Profile Service in SharePoint 2013 Foundation, is there some workaround to retrieve profile properties of a current logged-in user, who is an AD user?

2 Answers 2


One can use below code to retrieve current logged-in user's profile details from Active Directory in SharePoint 2013 Foundation.

string userLogin = SPContext.Current.Web.CurrentUser.LoginName;
                // To get the right context, run with elevated privileges  
                    var principalContext = new PrincipalContext(ContextType.Domain);
                    var userPrincipal = UserPrincipal.FindByIdentity(principalContext, System.DirectoryServices.AccountManagement.IdentityType.SamAccountName, userLogin);

                    lblName.Text = userPrincipal.Name;

                    if (userPrincipal != null)
                        DirectoryEntry directoryEntry = userPrincipal.GetUnderlyingObject() as DirectoryEntry;
                        lblPhoneNumber.Text = directoryEntry.Properties["telephoneNumber"].Value.ToString();                        
                        lblDepartment.Text = directoryEntry.Properties["department"].Value.ToString();
                        lblCompany.Text = directoryEntry.Properties["company"].Value.ToString();                            
                        //You can pull required details from active directory.


If you dont mind to do it programmably you can use is JavaScript object model - https://msdn.microsoft.com/en-us/library/office/jj920104.aspx


You can use it REST API - https://social.technet.microsoft.com/wiki/contents/articles/31210.sharepoint-2013-get-user-details-from-person-or-group-field-using-rest-api.aspx

Hope this is help somehow

  • I can't use JSOM as it is SharePoint Foundation 2013. May 5, 2017 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.