Rev | Line | |
---|
[6050] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Web;
|
---|
| 5 | using HLWebOKBAdminPlugin.OKBAdministrationService;
|
---|
| 6 | using System.ServiceModel.Security;
|
---|
| 7 |
|
---|
| 8 | namespace HLWebOKBAdminPlugin.Helpers {
|
---|
[6317] | 9 | public class Admin {
|
---|
[6050] | 10 |
|
---|
[6317] | 11 | public static AdministrationServiceClient GetClientFactory() {
|
---|
| 12 | return GetClientFactory(GetSessionString("Username"), GetSessionString("Password"));
|
---|
| 13 | }
|
---|
[6050] | 14 |
|
---|
[6317] | 15 | public static AdministrationServiceClient GetClientFactory(string username, string password) {
|
---|
| 16 | try {
|
---|
| 17 | AdministrationServiceClient adminClient = new AdministrationServiceClient();
|
---|
| 18 | adminClient.ClientCredentials.UserName.UserName = username;
|
---|
| 19 | adminClient.ClientCredentials.UserName.Password = password;
|
---|
| 20 | adminClient.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
|
---|
| 21 | return adminClient;
|
---|
| 22 | }
|
---|
| 23 | catch {
|
---|
| 24 | }
|
---|
| 25 | return null;
|
---|
| 26 | }
|
---|
[6050] | 27 |
|
---|
[6317] | 28 | public static string GetSessionString(string name) {
|
---|
| 29 | if (name != null) {
|
---|
| 30 | object o = HttpContext.Current.Session[name];
|
---|
| 31 | if (o != null) {
|
---|
| 32 | return o.ToString();
|
---|
[6050] | 33 | }
|
---|
[6317] | 34 | }
|
---|
| 35 | return string.Empty;
|
---|
[6050] | 36 | }
|
---|
[6317] | 37 | }
|
---|
[6050] | 38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.