1) employee login : should be in the form DomainName\username
2) Group name : which is group name you have created in sharepoint site.
Add web reference to http://
Also put your server name where I have indicated below
[WebMethod]
public String IsMOSSUserGroup(String employeeUserName, String group)
{
try
{
ServerName.UserGroup objWebService = new ServerName.UserGroup();
objWebService.Credentials = System.Net.CredentialCache.DefaultCredentials;
System.Xml.XmlNode ndGroups = objWebService.GetGroupCollectionFromUser(employeeUserName);
Boolean blnFound = false;
String strGroup = group;
foreach (System.Xml.XmlNode xmlGroup in ndGroups.ChildNodes[0].ChildNodes)
{
if (strGroup == xmlGroup.Attributes["Name"].Value)
{
blnFound = true;
}
}
if (blnFound == true)
{
return "Yes";
}
else
{
return "No";
}
}
catch (Exception ex)
{
return ex.Message;
}
}
This web service will return Yes if the given user belongs to the given sharepoint group.
No comments:
Post a Comment