WSS 3.0 and MOSS 2007 give developers ability to manage it’s resources by Web Services. With their help You can do things like add attachment to the specified list item or add a new user to the site collection. Full list of Web Services can be found here. Exception is SharePoint 2010 which doesn’t provide Web Services(asmx), but it enables communication through WCF(details here).

Using this Web Services is very simple. Below is a simple part of code, which returns information about specified user:

1. Add web reference to the Web Service http://<sitecollection>/_vti_bin/UserGroup.asmx

2. Contact with Web Service and get information


wsUsersGroups.UserGroup _WSUsersGroups = new wsUsersGroups.UserGroup();//Create new instance

if(UsingDefaultCredentials)//Using current user credentials or not
{
 _WSUsersGroups.UseDefaultCredentials = true;
}
else
{
 _WSUsersGroups.UseDefaultCredentials = false;
 _WSUsersGroups.Credentials = new NetworkCredential("user", "password", "domain");
}

XmlNode mainNode = WSUsersGroups.GetUserInfo("domain\\user");

if (mainNode == null)
{
 result = "Selected user cannot be found!";
 return;
}

XmlNode userInfo = mainNode.FirstChild;

result += "User ID:" + userInfo.Attributes["ID"].Value + Environment.NewLine;
result += "Name:" + userInfo.Attributes["Name"].Value + Environment.NewLine;
result += "E-mail:" + userInfo.Attributes["Email"].Value + Environment.NewLine;
result += "Is site admin:" + userInfo.Attributes["IsSiteAdmin"].Value + Environment.NewLine;

MessageBox.Show(result);