Esempio n. 1
0
        /// <summary>
        /// Gets all users associated with sms postini account
        /// </summary>
        /// <returns>A array of valid UserRecords or Null</returns>
        public UserRecord[] GetUsers()
        {
            if (this.CheckAuthEmail() == false)
            {
                return null;
            }

            if (this.CheckAuthPassword() == false)
            {
                return null;
            }

            try
            {
                //Create an Instance of the authElement
                AuthElem authCredentials = new AuthElem();

                // populate the ife authelement
                authCredentials.apiKey = this.strApiKey;
                authCredentials.email = this.strEmail;
                authCredentials.pword = this.strPassword;

                // Setup our WS request.
                GetUsersCriteria criteria = new GetUsersCriteria();

                // Show every user in the account hierarchy this admin has permissions to view.
                criteria.InAccountOrgHierarchy = true;

                GetUsersControl control = new GetUsersControl();

                // Return alias information for users.
                control.ReturnAliases = true;
                // Return API Attributes for users.
                control.ReturnAttributes = true;
                // Return approved sender addresses for users.
                control.ReturnApprovedSenderAddresses = true;
                // Return blocked sender addresses for users.
                control.ReturnBlockedSenderAddresses = true;

                // Retrieve users
                UserSyncService syncService = new UserSyncService();

                UserRecord[] userRecords = syncService.GetUsers(authCredentials, criteria, control);

                return userRecords;
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                String realSoapExceptionName = ex.Detail.FirstChild.LocalName;
                String realSoapExceptionMessage = ex.Detail.FirstChild.InnerText;
                if(blnDebug)
                Console.WriteLine("Postinilib: GetUsers error, Soap Exception: " +
                    realSoapExceptionName + " - " + realSoapExceptionMessage);
                return null;
            }
            catch (Exception ex)
            {
                if(blnDebug)
                    Console.WriteLine("Postinilib: GetUsers error " + ex.Message);
                return null;
            }
        }