public bool AddUser(string adminUsername, string adminPswd, string username, string password, string commonName, string email) { var client = new SPMLSoapClient.SPML(); // Set request type var addRequest = new SPMLSoapClient.AddRequestType(); // add admin logon data var logonData = new SPMLSoapClient.CoSignLogonData(); logonData.User = adminUsername; logonData.Password = adminPswd; addRequest.CoSignLogonData = logonData; // admin logon info addRequest.returnData = SPMLSoapClient.ReturnDataType.data; // add user data addRequest.UserRecord = new SPMLSoapClient.UserRecord(); addRequest.UserRecord.UserLoginName = username; addRequest.UserRecord.Password = password; addRequest.UserRecord.UserCN = commonName; addRequest.UserRecord.EmailAddress = email; addRequest.UserRecord.RightsMask = 1; //1=User, 2=Appliance mngmnt, 4=User mngmnt addRequest.UserRecord.UserKind = SPMLSoapClient.UserKindEnum.User; addRequest.psoID = new SPMLSoapClient.PSOIdentifierType(); addRequest.psoID.ID = username; SPMLSoapClient.AddResponseType response; try { response = client.add(addRequest); if (response.status != SPMLSoapClient.StatusCodeType.success) { MessageBox.Show("Error on Add: " + response.status + ", " + response.error + ", " + response.errorMessage[0], "Error"); return(false); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); return(false); } if (response.pso == null) { //..... return(false); } return(true); }
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); }