3
API usage and authentication?
Question asked by Eric Tykwinski - 8/24/2020 at 1:22 PM
Unanswered
SmarterMail Build 7523
So a lot of the automation stuff I could do in the Legacy API seems to be harder for me in the new one.  I can login and get my authentication token as System Admin fine, I can query "/api/v1/settings/sysadmin/export-domains-list" and get a nice csv of the domains on the server, but unsure how to query domain related stuff, since "api/v1/settings/domain/primary-admin" is limited to Domain Admins, and that is the user I want to use "api/v1/auth/retrieve-login-token" on...

If you are wondering, I saw about losing the list of ActiveSync users and last sync, which seems pretty easy to do in SOAP, but figured I should write it in the new REST API since I may as well get used to it.  I'm thinking that I'm just missing something with the new authentication scheme in this API system.

1 Reply

Reply to Thread
1
Eric Tykwinski Replied
If anyone is interested, I wrote a quick and dirty audit script in the old API:
#!/usr/bin/python3
from suds.client import Client
ServerAdmin = "Username"
ServerPassword = "Password"
SmarterMailServer="https://mail.domain.com"
DomainURL=SmarterMailServer + "/Services/svcDomainAdmin.asmx?WSDL"
client = Client(DomainURL)
#print(client)
domains = client.service.GetAllDomains(AuthUserName = ServerAdmin, AuthPassword = ServerPassword)
DomainList = domains.DomainNames[0]
ActiveSyncURL=SmarterMailServer + "/Services/svcUserAdmin.asmx?WSDL"
client = Client(ActiveSyncURL)
i = 0
while i < len(DomainList):
        print(DomainList[i])
        ActiveSyncUsers = client.service.GetActiveSyncUsers2(AuthUserName = ServerAdmin, AuthPassword = ServerPassword, DomainName = DomainList[i])
        print(ActiveSyncUsers)
        i += 1

Reply to Thread