I have one custom list with fields like

  • ID,
  • Name,
  • Phone no

When Ii add a new item to the list a new item form will be opened. While filling the form by entering the first field (ID), I want other fields to be auto-populated from Active Directory.

Is it possible through Browser (UI) or from SharePoint Designer?

2 Answers 2


I assume that your SharePoint version is 2013 and User Profile service is working fine on your environment. You can use REST API to get user information from User Profile Service.

  url: "http://<site url>/_api/sp.userprofiles.peoplemanager
    /getuserprofilepropertyfor(accountame=@v, propertyname='PictureURL')
  type: "GET",
  headers: { "accept": "application/json;odata=verbose" },
  success: successHandler,
  error: errorHandler

msdn reference


You can use this piece of code to fetch data from Active Directory using JavaScript and then with the help of SPUtility or JavaScript set the value of fields.

function getUserName() { 
var wshNetwork = new ActiveXObject("WScript.Network"); 
var userName = wshNetwork.UserName; 
return userName;
function getAD(userName) {  //var name = userName.split(".");
objConnection = new ActiveXObject("ADODB.Connection"); 
objConnection.Provider = "ADsDSOObject"; 
objConnection.Open("ADs Provider"); 
objCommand = new ActiveXObject("ADODB.Command"); 
objCommand.ActiveConnection = objConnection;  
objCommand.CommandText = "SELECT sAMAccountName, ID, Phone FROM 'LDAP://ad.mycompany.com/OU=User Accounts,OU=User Directory,DC=ad,DC=mycompany,DC=com' WHERE objectCategory='user' and sAMAccountName = '" + userName + "'";   /* Next up is the command itself.*/  
objRecordSet = objCommand.Execute();   /* Then we execute the command */   /* Once executed, the command will return an enumeration of the results.*/   
var Id, Phone, Name; 
if (objRecordSet.RecordCount == 1) {  
    Id= objRecordSet.Fields("Id").value;  
    Name= objRecordSet.Fields("givenName").value;  
    Phone= objRecordSet.Fields("Phone").value; 
else  {   
    Id= "";  
    Name= "";  
    Phone= ""; 
return userMail + ";" + firstName + ";" + lastName;
var AD = getAD(getUserName()).split(";"); 
var Id= AD[0];
var Name= AD[1];
var Phone= AD[2];

You can use above variables to set Fields in edit or new form using SPUtility. For Eg.

SPUtility.GetSPField('Name').SetValue('Hello world!');

For more reference on SPUtility refer this link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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