private void button1_Click(object sender, EventArgs e) { var client = new SPMLSoapClient.SPML(); // build the CoSign Logon Data var data = new SPMLSoapClient.CoSignLogonData(); data.User = txtUsername.Text; data.Password = txtPassword.Text; // buils a search request var searchRequest = new SPMLSoapClient.SearchRequestType(); searchRequest.CoSignLogonData = data; searchRequest.returnData = SPMLSoapClient.ReturnDataType.data; searchRequest.maxSelect = 20; // number of users to fetch searchRequest.maxSelectSpecified = true; SPMLSoapClient.SearchResponseType response; try { // make the call response = client.search(searchRequest); if (response.status != SPMLSoapClient.StatusCodeType.success) { MessageBox.Show("Error on search: " + response.status + ", " + response.error + ", " + response.errorMessage[0], "Error"); return; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); return; } if (response.pso == null) { MessageBox.Show("No users!", "OK"); return; } //populate the text box with the users from the response for (int i = 0; i < response.pso.Length; i++) { String usrs = (i + 1) + ": " + response.pso[i].psoID.ID + ", " + response.pso[i].UserRecord.UserCN + "," + response.pso[i].UserRecord.EmailAddress + ", " + response.pso[i].UserRecord.RightsMask; richTextBox1.Text += (usrs + "\n"); } }
public SPMLSoapClient.PSOType[] ListUsers(string adminUsername, string adminPswd) { var client = new SPMLSoapClient.SPML(); var data = new SPMLSoapClient.CoSignLogonData(); data.User = adminUsername; data.Password = adminPswd; //data.Domain = ""; // Get a list of users var searchRequest = new SPMLSoapClient.SearchRequestType(); searchRequest.CoSignLogonData = data; searchRequest.returnData = SPMLSoapClient.ReturnDataType.data; searchRequest.maxSelect = 20; // number of records to extract searchRequest.maxSelectSpecified = true; SPMLSoapClient.SearchResponseType response; try { response = client.search(searchRequest); if (response.status != SPMLSoapClient.StatusCodeType.success) { MessageBox.Show("Error on search: " + response.status + ", " + response.error + ", " + response.errorMessage[0], "Error"); return(null); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); return(null); } if (response.pso == null) { MessageBox.Show("No users!", "OK"); return(null); } return(response.pso); }