Methods

addressbook

(source code)
addressbook(word, setup)
Find an user based on a part of his name

Parameters:

String
word Optional
A part of the name from the guy you're looking for
Object
setup Optional
Options (see below)
String
setup.limit Optional, Default: 10
Number of results returned
String
setup.type Optional, Default: 'User'
Possible values are: 'All', 'DistributionList', 'SecurityGroup', 'SharePointGroup', 'User', and 'None' (see http://msdn.microsoft.com/en-us/library/people.spprincipaltype.aspx)
String
setup.url Optional, Default: 'current website'
The website url

Returns:

Promise
resolve([{AccountName,UserInfoID,DisplayName,Email,Departement,Title,PrincipalType}]), reject(error)

Example:

$SP().addressbook("john", {limit:25}).then(function(people) {
    for (var i=0; i < people.length; i++) {
      for (var j=0; j < people[i].length; j++) console.log(people[i][j]+" = "+people[i][people[i][j]]);
    }
  });

distributionLists

(source code)
distributionLists(username, setup)
Find the distribution lists where the specified user is member of

Parameters:

String
username
The username with or without the domain ("domain\\login" for Sharepoint 2010, or e.g. "i:0#.w|domain\\login" for Sharepoint 2013)
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Boolean
setup.cache Optional, Default: true
Cache the response from the server

Returns:

Promise
resolve(mailings), reject(error)

Example:

$SP().distributionLists("mydomain\\john_doe",{url:"http://my.si.te/subdir/"}).then(function(mailing) {
    for (var i=0; i < mailing.length; i++) console.log(mailing[i]); // -> {SourceReference: "cn=listname,ou=distribution lists,ou=rainbow,dc=com", DisplayName:"listname", MailNickname:"List Name", Url:"mailto:listname@rainbow.com"}
  });

getManager

(source code)
getManager(username, setup)
Return the manager for the provided user, as a People string

Parameters:

String
username Optional
Username with the domain, and if you leave it empty it's the current user by default
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Function
setup.modify Optional
Permits to modify the manager's username returned by the service

Returns:

function
resolve(manager), reject(error)

Example:

$SP().getManager("domain\\john_doe",{url:"http://my.si.te/subdir/"})
  .then(function(manager) {
    console.log(manager); // 42;#Smith,, Jane,#i:0#.w|domain\Jane_Smith,#Jane_Smith@Domain.com,#Jane_Smith@Domain.com,#Smith,, Jane
    manager = $SP().getPeopleLookup(manager);
    console.log(manager.name); // "Smith, Jane"
  })
  .catch(function(err) {
    console.log("Err => ",err)
  });

  $SP().getManager("domain\\john_doe",{
    modify:function(managerUserName) {
      return (managerUserName.startsWith('i:0') ? managerUserName : "i:0#.w|" + managerUserName);
    }
  })

getUserInfo

(source code)
getUserInfo(username, setup)
Find the User ID, work email, and preferred name for the specified username (this is useful because of the User ID that can then be used for filtering a list)

Parameters:

String
username
That must be "domain\\login" for Sharepoint 2010, or something like "i:0#.w|domain\\login" for Sharepoint 2013
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url

Returns:

Promise
resolve({ID,Sid,Name,LoginName,Email,Notes,IsSiteAdmin,IsDomainGroup,Flags}), reject(error)

Example:

$SP().getUserInfo("domain\\john_doe",{url:"http://my.si.te/subdir/"}).then(function(info) {
    alert("User ID = "+info.ID)
  }, function(error) {
    console.log(error)
  });

groupMembers

(source code)
groupMembers(groupname, setup)
Find the members of a Sharepoint group

Parameters:

String
groupname
Name of the group
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Boolean
setup.cache Optional, Default: true
By default the function will cache the group members (so if you call several times it will use the cache)

Returns:

Promise
resolve(members), reject(error)

Example:

$SP().groupMembers("my group").then(function(members) {
    for (var i=0; i < members.length; i++) console.log(members[i]); // -> {ID:"1234", Name:"Doe, John", LoginName:"mydomain\john_doe", Email:"john_doe@rainbow.com"}
  });

isMember

(source code)
isMember(setup)
Find if the user is member of the Sharepoint group

Parameters:

Object
setup Optional
Options (see below)
String
setup.user
Username with domain ("domain\\login" for Sharepoint 2010, or e.g. "i:0#.w|domain\\login" for Sharepoint 2013)
String
setup.group
Name of the group
String
setup.url Optional, Default: 'current website'
The website url
Boolean
setup.cache Optional, Default: true
Cache the response from the server

Returns:

PRomise
resolve(isMember), reject(error)

Example:

$SP().isMember({user:"mydomain\\john_doe",group:"my group",url:"http://my.site.com/"}).then(function(isMember) {
    if (isMember) alert("OK !")
  });

people

(source code)
people(username, setup)
Find the user details like manager, email, ...

Parameters:

String
username Optional
The username (e.g. domain\\john_doe)
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url

Returns:

function
resolve(people), reject(error)

Example:

$SP().people("john_doe",{url:"http://my.si.te/subdir/"}).then(function(people) {
    for (var i=0; i < people.length; i++) console.log(people[i]+" = "+people[people[i]]);
  }, function(err) {
    console.log("Err => ",err)
  });

usergroups

(source code)
usergroups(username, setup)
Find the Sharepoint groups where the specified user is member of

Parameters:

String
username
The username with the domain ("domain\\login" for Sharepoint 2010, or e.g. "i:0#.w|domain\\login" for Sharepoint 2013)
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Boolean
setup.cache Optional, Default: true
Keep a cache of the result

Returns:

Promise
result(groups), reject(error)

Example:

$SP().usergroups("mydomain\\john_doe",{url:"http://my.si.te/subdir/"}).then(function(groups) {
    for (var i=0; i < groups.length; i++) console.log(groups[i]); // -> "Roadmap Admin", "Global Viewers", ...
  });

whoami

(source code)
whoami(setup)
Find the current user's details like manager, email, colleagues, ...

Parameters:

Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url

Returns:

Promise
resolve(people), reject(error)

Example:

$SP().whoami({url:"http://my.si.te/subdir/"}).then(function(people) {
    for (var i=0; i < people.length; i++) console.log(people[i]+" = "+people[people[i]]);
  });