Methods

addressbook

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

Parameters:

String
word
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
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result (typically: AccountName,UserInfoID,DisplayName,Email,Departement,Title,PrincipalType)

Example:

$SP().addressbook("john", {limit:25}, 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, result)
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
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result

Example:

$SP().distributionLists("mydomain\\john_doe",{url:"http://my.si.te/subdir/"}, 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"}
});

getUserInfo

(source code)
getUserInfo(username, setup, result)
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
Function
result Optional
A function that will be executed at the end of the request with a param that is an object with the result ({ID,Sid,Name,LoginName,Email,Notes,IsSiteAdmin,IsDomainGroup,Flags}), or a String with the error message

Example:

$SP().getUserInfo("domain\\john_doe",{url:"http://my.si.te/subdir/"}, function(info) {
  if (typeof info === "string") {
    alert("Error:"+info); // there was a problem so we show it
  } else
    alert("User ID = "+info.ID)
});

groupMembers

(source code)
groupMembers(groupname, setup, result)
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.error Optional, Default: true
The function will stop and throw an error when something went wrong (use FALSE to don't throw an error)
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)
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result

Example:

$SP().groupMembers("my group", 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, result)
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
Function
result Optional
Return TRUE if the user is a member of the group, FALSE if not.

Example:

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

people

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

Parameters:

String
username Optional
With or without the domain, and you can also use an email address, and if you leave it empty it's the current user by default (if you use the domain, don't forget to use a double \ like "mydomain\\john_doe")
Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result, or a String with the error message

Example:

$SP().people("john_doe",{url:"http://my.si.te/subdir/"}, function(people) {
  if (typeof people === "string") {
    alert(people); // there was a problem so we prompt it
  } else
    for (var i=0; i < people.length; i++) console.log(people[i]+" = "+people[people[i]]);
});

usergroups

(source code)
usergroups(username, setup, result)
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.error Optional, Default: true
The function will stop and throw an error when something went wrong (use FALSE to don't throw an error)
Boolean
setup.cache Optional, Default: true
Keep a cache of the result
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result

Example:

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

whoami

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

Parameters:

Object
setup Optional
Options (see below)
String
setup.url Optional, Default: 'current website'
The website url
Function
result Optional
A function that will be executed at the end of the request with a param that is an array with the result

Example:

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