forked from ilgarm/pyzimbra
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
421 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
################################################################################ | ||
# Copyright (c) 2010, Ilgar Mashayev | ||
# | ||
# E-mail: [email protected] | ||
# Website: http://github.com/ilgarm/pyzimbra | ||
################################################################################ | ||
# This file is part of pyzimbra. | ||
# | ||
# Pyzimbra is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Pyzimbra is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with Pyzimbra. If not, see <http://www.gnu.org/licenses/>. | ||
################################################################################ | ||
Authentication samples. | ||
@author: ilgar | ||
""" | ||
from pyzimbra import soap | ||
from pyzimbra.base import ZimbraClientException | ||
from pyzimbra.soap_auth import SoapAuthenticator | ||
from pyzimbra.soap_transport import SoapTransport | ||
from sample.util import load_properties | ||
import pconstant | ||
|
||
|
||
def authenticate(): | ||
p = load_properties() | ||
|
||
transport = SoapTransport() | ||
transport.debug = 1 | ||
transport.soap_url = soap.admin_soap_url(p[pconstant.ADMIN_HOSTNAME]) | ||
|
||
auth = SoapAuthenticator() | ||
auth_token = auth.authenticate_admin(transport, | ||
p[pconstant.ADMIN_ACCOUNT_NAME], | ||
p[pconstant.ADMIN_PASSWORD]) | ||
|
||
print auth_token.token | ||
|
||
|
||
if __name__ == '__main__': | ||
try: | ||
authenticate() | ||
except ZimbraClientException, e: | ||
e.print_trace() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
################################################################################ | ||
# Copyright (c) 2010, Ilgar Mashayev | ||
# | ||
# E-mail: [email protected] | ||
# Website: http://github.com/ilgarm/pyzimbra | ||
################################################################################ | ||
# This file is part of pyzimbra. | ||
# | ||
# Pyzimbra is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Pyzimbra is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with Pyzimbra. If not, see <http://www.gnu.org/licenses/>. | ||
################################################################################ | ||
Account info samples. | ||
@author: ilgar | ||
""" | ||
from pyzimbra import sconstant, zconstant, soap | ||
from pyzimbra.soap_auth import SoapAuthenticator | ||
from pyzimbra.soap_transport import SoapTransport | ||
from pyzimbra.zclient import ZimbraClient | ||
from sample.util import load_properties | ||
import SOAPpy | ||
import pconstant | ||
|
||
|
||
def get_account(): | ||
p = load_properties() | ||
|
||
transport = SoapTransport() | ||
transport.debug = 1 | ||
transport.soap_url = soap.admin_soap_url(p[pconstant.ADMIN_HOSTNAME]) | ||
|
||
auth = SoapAuthenticator() | ||
|
||
zclient = ZimbraClient() | ||
zclient.transport = transport | ||
|
||
zclient.authenticate_admin(auth, | ||
p[pconstant.ADMIN_ACCOUNT_NAME], | ||
p[pconstant.ADMIN_PASSWORD]) | ||
|
||
attrs = {sconstant.A_BY: sconstant.V_NAME} | ||
account = SOAPpy.Types.stringType(data=p[pconstant.ACCOUNT_NAME], attrs=attrs) | ||
|
||
params = {sconstant.E_ACCOUNT: account} | ||
res = zclient.invoke(zconstant.NS_ZIMBRA_ADMIN_URL, | ||
sconstant.GetAccountRequest, | ||
params) | ||
|
||
print res | ||
|
||
|
||
if __name__ == '__main__': | ||
get_account() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.