/// <summary> /// SuspendUser - Suspend a Single user from Postini based on email address /// </summary> /// <param name="strUserEmailAddress">Email address of user to suspend</param> /// <returns>true on success or false on failure</returns> public bool SuspendUser(String strUserEmailAddress) { if (this.CheckAuthEmail() == false) { return false; } if (this.CheckAuthPassword() == false) { return false; } try { // Create an instance of AutomatedBatch Reference AutomatedBatchAPI.AutomatedBatchService wsSuspendUser = new AutomatedBatchAPI.AutomatedBatchService(); // Create an Instance of the authElement AutomatedBatchAPI.authElem authCredentials = new AutomatedBatchAPI.authElem(); // Get the email address and password entered by the user Use the // xauth method instead of pword if the authentication is XAuth authCredentials.apiKey = strApiKey; authCredentials.email = strEmail; authCredentials.pword = strPassword; // Retrieve the endpoint for the specified auth email and service, // setting it for our Automated Batch service. wsSuspendUser.Url = this.GetServiceEndpoint(strUserEmailAddress); if (wsSuspendUser.Url == null) { if (blnDebug) Console.WriteLine("Postinilib: SuspendUser failed, null endpoint url"); return false; } // SuspendUser Web Service request wsSuspendUser.suspenduser(authCredentials, strUserEmailAddress, null, null, null); if (blnDebug) Console.WriteLine("Successfully Suspended user."); } catch (System.Web.Services.Protocols.SoapException ex) { String realSoapExceptionName = ex.Detail.FirstChild.LocalName; String realSoapExceptionMessage = ex.Detail.FirstChild.InnerText; if (blnDebug) Console.WriteLine("Postinilib: SuspendUser error, Soap Exception: " + realSoapExceptionName + " - " + realSoapExceptionMessage); return false; } catch (Exception ex) { if (blnDebug) Console.WriteLine("Postinilib: SuspendUser error " + ex.Message); return false; } return true; }
/// <summary> /// AddUser - Adds a User to Postini /// </summary> /// <param name="strEmail"></param> /// <returns>returns true on success or false on failure</returns> public bool AddUser(String strUserEmailAddress) { if (this.CheckAuthEmail() == false) { return false; } if (this.CheckAuthPassword() == false) { return false; } try { // Create an instance of AutomatedBatch Reference AutomatedBatchAPI.AutomatedBatchService wsAddUser = new AutomatedBatchAPI.AutomatedBatchService(); // Create an Instance of the authElement AutomatedBatchAPI.authElem authCredentials = new AutomatedBatchAPI.authElem(); // Get the email address and password entered by the user Use the // xauth method instead of pword if the authentication is XAuth authCredentials.apiKey = strApiKey; authCredentials.email = strEmail; authCredentials.pword = strPassword; // Retrieve the endpoint for the specified auth email and service, // setting it for our Automated Batch service. wsAddUser.Url = this.GetServiceEndpoint(strUserEmailAddress); if (wsAddUser.Url == null) { if (blnDebug) Console.WriteLine("Postinilib: AddUser failed, null endpoint url"); return false; } // Create an instance of the extra argument structure for adduser AutomatedBatchAPI.adduserargs userExtraArgs = new AutomatedBatchAPI.adduserargs(); // adduser arguments are user address, fields, org, and welcome // userExtraArgs.org = "<org name entered by user>"; // welcome message to users upon account creation userExtraArgs.welcome = "Welcome to simplymailsolutions"; // AddUser Web Service request wsAddUser.adduser(authCredentials, strUserEmailAddress, userExtraArgs); // Display the web service output if (blnDebug) Console.WriteLine("Successfully added new user."); } catch (System.Web.Services.Protocols.SoapException ex) { String realSoapExceptionName = ex.Detail.FirstChild.LocalName; String realSoapExceptionMessage = ex.Detail.FirstChild.InnerText; if (blnDebug) Console.WriteLine("Postinilib: Adduser error, Soap Exception: " + realSoapExceptionName + " - " + realSoapExceptionMessage); return false; } catch (Exception ex) { if(blnDebug) Console.WriteLine("Postinilib: Adduser error " + ex.Message); return false; } return true; }