private async Task <ZimbraMessage> ProcessAdministrationMessage(ZimbraMessage zimbraMessage) { if (administration == null) { administration = new ZimbraAdminSoapClient(binding, remoteAddressAdmin); } object message = await ProcessMessage(administration, zimbraMessage); return(message as ZimbraMessage); }
public void Dispose() { if (account != null) { account.InnerChannel.Dispose(); account = null; } if (administration != null) { administration.InnerChannel.Dispose(); administration = null; } }
private void GetVersionInfo(bool asAdmin = false) { if (asAdmin) { Zimbra.Administration.GetVersionInfoResponse Adminresponse; if (administration == null) { administration = new ZimbraAdminSoapClient(binding, remoteAddressAdmin); } Zimbra.Administration.GetVersionInfoRequest Adminrequest = new Administration.GetVersionInfoRequest { }; Adminresponse = administration.GetVersionInfoRequest(Adminrequest); if (Adminresponse.info != null) { string BuildDate = Adminresponse.info.buildDate; } } try { Zimbra.Account.GetVersionInfoResponse response; if (account == null) { account = new ZimbraAccountSoapClient(binding, remoteAddress); } Zimbra.Account.GetVersionInfoRequest request = new Account.GetVersionInfoRequest { }; response = account.GetVersionInfoRequest(request); if (response.info != null) { string BuildDate = response.info.buildDate; } } catch (FaultException fex) { Console.Write(fex.Message); //throw fex; } catch (Exception ex) { Console.Write(ex.Message); //throw ex; } }
public string Authenticate(string UserName, string Password, bool IsAdmin = false) { try { //configuration.Server.UserName = UserName; //configuration.Server.Password = Password; //configuration.Server.IsAdmin = IsAdmin; string AuthToken = string.Empty; if (IsAdmin) { //ZimbraEndpointAddress.ZimbraHeaderContext = new ZimbraHeaderContext(); Zimbra.Administration.AuthResponse response; if (administration == null) { administration = new ZimbraAdminSoapClient(binding, remoteAddressAdmin); } NoOpResponse noop = new NoOpResponse(); if (!string.IsNullOrWhiteSpace(ZimbraEndpointAddress.ZimbraHeaderContext.authToken)) { noop = administration.NoOpRequest(new NoOpRequest { }); } if (noop != null) { noop.Dispose(); } if (string.IsNullOrWhiteSpace(ZimbraEndpointAddress.ZimbraHeaderContext.authToken)) { Zimbra.Administration.AuthRequest request = new Administration.AuthRequest { account = new Global.accountSelector { by = Global.accountBy.AdministratorName, Value = UserName }, password = Password, persistAuthTokenCookie = true }; response = administration.AccountAuth(request); if (!string.IsNullOrEmpty(response.authToken)) { ZimbraEndpointAddress.ZimbraHeaderContext.authToken = response.authToken; ZimbraEndpointAddress.ZimbraHeaderContext.AuthTokenControl = new authTokenControl { voidOnExpired = true }; ZimbraEndpointAddress.ZimbraHeaderContext.account = request.account.Value; //ZimbraEndpointAddress.ZimbraHeaderContext.account.by = accountBy.name; AuthenticatedAdminLifetime = response.lifetime; AuthenticatedAdmin = true; AuthToken = response.authToken; } } } else { //ZimbraEndpointAddress.ZimbraHeaderContext = new ZimbraHeaderContext(); Zimbra.Account.AuthResponse response; if (account == null) { account = new ZimbraAccountSoapClient(binding, remoteAddress); } Zimbra.Account.AuthRequest request = new Account.AuthRequest { account = new Global.accountSelector { by = Global.accountBy.Name, Value = UserName }, password = Password, persistAuthTokenCookie = true }; response = account.AccountAuth(request); if (!string.IsNullOrEmpty(response.authToken)) { AuthenticatedLifetime = response.lifetime; Authenticated = true; AuthToken = response.authToken; } //ZimbraEndpointAddress.ZimbraHeaderContext.authToken = response.authToken; //ZimbraEndpointAddress.ZimbraHeaderContext.AuthTokenControl = new authTokenControl { voidOnExpired = true }; //ZimbraEndpointAddress.ZimbraHeaderContext.account = request.account.Value; } //GetVersioInfo(asAdmin); return(AuthToken); } catch (Exception ex) { HttpRuntime.UnloadAppDomain(); Thread.Sleep(100); throw ex; } }