Thursday, May 5, 2011

Exception of type Microsoft.SharePoint.SoapServer.SoapServerExceptio n was thrown

I got an error while trying to add user to a group in SharePoint 2010.
Web_Reference.UserGroup userGroup = new Web_Reference.UserGroup();
            userGroup.Credentials = System.Net.CredentialCache.DefaultCredentials;
            userGroup.Url = @"URL Of the Site/_vti_bin/UserGroup.asmx";
            string groupName = "Employees";
            string userName = "Bijay";
            string userLoginName = "Bijay";
            string userEmail = "myemail@gmail.com";
            string userNotes = "User Added from Client tool";

            userGroup.AddUserToGroup(groupName, userName, userLoginName, userEmail, userNotes);
           
             //same way you can also remove user from the group by using the following object model.
           
            userGroup.RemoveUserFromGroup(groupName, userLoginName);

After executing the error I got the following error


System.Web.Services.Protocols.SoapException: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerExcepti on' was thrown.

But when I updated the strings to the following format that works for me.

            string userName = "Bijay Kumar";
            string userLoginName = "domain name / sahoobij";
            string userEmail = "myemail@domainname.com";

still I am not sure whther it is the right solution or not but I solved the issue.

No comments:

Post a Comment