using System; using System.Collections.Generic; using System.Linq; using System.Web; using HLWebOKBAdminPlugin.OKBAdministrationService; using System.ServiceModel.Security; namespace HLWebOKBAdminPlugin.Helpers { public class Admin { public static AdministrationServiceClient GetClientFactory() { return GetClientFactory(GetSessionString("Username"), GetSessionString("Password")); } public static AdministrationServiceClient GetClientFactory(string username, string password) { try { AdministrationServiceClient adminClient = new AdministrationServiceClient(); adminClient.ClientCredentials.UserName.UserName = username; adminClient.ClientCredentials.UserName.Password = password; adminClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; return adminClient; } catch { } return null; } public static string GetSessionString(string name) { if (name != null) { object o = HttpContext.Current.Session[name]; if (o != null) { return o.ToString(); } } return string.Empty; } } }