Dws.RemoveDwsUser Method
Removes the specified user from the list of users for the current Document Workspace site.
Namespace: [DWS Web service]
Web service reference: http://Site/_vti_bin/DWS.asmx
Syntax
'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/dws/RemoveDwsUser", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/dws/", _
ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/dws/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function RemoveDwsUser ( _
id As String _
) As String
'Usage
Dim instance As Dws
Dim id As String
Dim returnValue As String
returnValue = instance.RemoveDwsUser(id)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/dws/RemoveDwsUser", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/dws/",
ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/dws/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public string RemoveDwsUser(
string id
)
Parameters
id
Type: System.StringThe ID of the user to remove from the list of users.
Return Value
Type: System.String
A string that returns an empty <Result/> tag when successful.
Exceptions
Exception | Condition |
---|---|
[DwsError.NoAccess(3)] | The user does not have sufficient rights. |
Remarks
The RemoveDwsUser method removes the specified user from the current Document Workspace site by specifying the user ID. However, the methods of the Document Workspace service do not provide access to ID values for users of the Document Workspace site. Use the GetUserInfo(String) method of the Microsoft Windows SharePoint Services Users and Groups Web service to retrieve user ID values.
Examples
The following code example shows how to retrieve the user ID by passing the account name of the user to the GetUserInfo method of the Users and Groups Web service, and then how to remove the user from the current Document Workspace site by passing the user ID to the RemoveDwsUser method. For more information about the full text of the helper functions used in this example, see the CanCreateDwsUrl method.
Try
'Get the member's id.
Dim usrWebService As server.UserGroup = New server.UserGroup()
Dim xmlUserInfo As System.Xml.XmlNode
Dim xnrUserInfo As System.Xml.XmlNodeReader
Dim strUserID As String
usrWebService.Credentials = myCredentials.DefaultCredentials
xmlUserInfo = usrWebService.GetUserInfo("DOMAIN\user_name")
xnrUserInfo = New XmlNodeReader(xmlUserInfo)
While xnrUserInfo.Read()
If xnrUserInfo.Name = "User" Then
strUserID = xnrUserInfo.GetAttribute("ID")
End If
End While
'Remove the member.
Dim strResult As String
strResult = dwsWebService.RemoveDwsUser(strUserID)
If IsDwsErrorResult(strResult) Then
Dim intErrorID As Integer
Dim strErrorMsg As String
Call ParseDwsErrorResult(strResult, intErrorID, strErrorMsg)
MessageBox.Show _
("A document workspace error occurred." & vbCrLf & _
"Error number: " & intErrorID.ToString & vbCrLf & _
"Error description:" & strErrorMsg, _
"DWS Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
MessageBox.Show("The user was successfully removed.", _
"Remove Dws User", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End If
Catch exc As Exception
MessageBox.Show("An exception occurred." & vbCrLf & _
"Description: " & exc.Message, _
"Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
try
{
//Get the member's ID.
server.UserGroup usrWebService = new server.UserGroup();
System.Xml.XmlNode xmlUserInfo;
System.Xml.XmlNodeReader xnrUserInfo;
string strUserID = "";
usrWebService.Credentials =
System.Net.CredentialCache.DefaultCredentials;
xmlUserInfo = usrWebService.GetUserInfo("DOMAIN\user_name");
xnrUserInfo = new System.Xml.XmlNodeReader(xmlUserInfo);
while (xnrUserInfo.Read())
{
if (xnrUserInfo.Name == "User")
{
strUserID = xnrUserInfo.GetAttribute("ID");
}
}
//Remove the member.
string strResult = "";
strResult = dwsWebService.RemoveDwsUser(strUserID);
if (IsDwsErrorResult(strResult))
{
int intErrorID = 0;
string strErrorMsg = "";
ParseDwsErrorResult(strResult, out intErrorID,
out strErrorMsg);
MessageBox.Show
("A document workspace error occurred.\r\n" +
"Error number: " + intErrorID.ToString() + "\r\n" +
"Error description: " + strErrorMsg,
"DWS Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show
("The user was successfully removed.",
"Remove Dws User", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
catch (Exception exc)
{
MessageBox.Show("An exception occurred.\r\n" +
"Description: " + exc.Message,
"Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}