This repository has been archived by the owner on Jan 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActiveDirectoryAuthenticationMethod.cs
109 lines (95 loc) · 7.64 KB
/
ActiveDirectoryAuthenticationMethod.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using Nop.Core;
using Nop.Services.Authentication.External;
using Nop.Services.Cms;
using Nop.Services.Configuration;
using Nop.Services.Localization;
using System.Collections.Generic;
using Nop.Services.Plugins;
namespace Nop.Plugin.ExternalAuth.NovellActiveDirectory
{
public class ActiveDirectoryAuthenticationMethod : BasePlugin, IExternalAuthenticationMethod, IPlugin, IWidgetPlugin
{
private readonly ISettingService _settingService;
private readonly ILocalizationService _localizationService;
private readonly IWebHelper _webHelper;
public ActiveDirectoryAuthenticationMethod(ISettingService settingService, IWebHelper webHelper, ILocalizationService localizationService)
{
_settingService = settingService;
_webHelper = webHelper;
_localizationService = localizationService;
}
public override string GetConfigurationPageUrl()
{
return $"{_webHelper.GetStoreLocation((bool?)null)}Admin/NovellActiveDirectoryAuthentication/Configure";
}
public bool HideInWidgetList => false;
public string GetPublicViewComponentName()
{
return "ActiveDirectoryAuthentication";
}
public string GetWidgetViewComponentName(string widgetZone)
{
return "WidgetsActiveDirectoryAuthentication";
}
public IList<string> GetWidgetZones()
{
return new List<string>
{
"header_links_before"
};
}
public override void Install()
{
_settingService.SaveSetting<NovellActiveDirectoryExternalAuthSettings>(new NovellActiveDirectoryExternalAuthSettings(), 0);
_localizationService.AddOrUpdatePluginLocaleResource( "Plugins.ExternalAuth.NovellActiveDirectory.LDAPPath", "AD Path", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LDAPPath.Hint", "Enter the path to your active directory like 'yourdirectory'", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapUsername", "AD username", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapUsername.Hint", "If needed, enter the username to connect to AD", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapPassword", "AD password", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapPassword.Hint", "If needed, enter the password to connect to AD", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapConnectError", "Could not connect to AD server", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.UserNotFound", "Windows user not found in AD", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.MailNotFound", "No email found for Windows user", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.WindowsUserNotAvailable", "Windows user not available. Please check if windows authentication is enabled and forwardWindowsAuthToken is set to true in web.config!", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.InstantLogin", "Instant login", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.InstantLogin.Hint", "Password-free logins", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapError", "Cannot establish connection to active directory!", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.fields.LdapPath.Required", "AD path cannot be empty", (string)null);
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.SearchBase", "Search Base");
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.ContainerName", "Container Name");
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.Domain", "Domain");
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.DomainDistinguishedName", "Domain Distinguished Name");
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapServerPort", "Ldap Server Port");
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.UseSSL", "Use SSL");
_localizationService.AddOrUpdatePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapPassword.Required", "Please enter your AD password");
base.Install();
}
public override void Uninstall()
{
_settingService.DeleteSetting<NovellActiveDirectoryExternalAuthSettings>();
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LDAPPath");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LDAPPath.Hint");
_localizationService.DeletePluginLocaleResource( "Plugins.ExternalAuth.NovellActiveDirectory.LdapUsername");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapUsername.Hint");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapPassword");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapPassword.Hint");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapConnectError");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.UserNotFound");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.MailNotFound");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.WindowsUserNotAvailable");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.InstantLogin");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.InstantLogin.Hint");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapError");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.fields.LdapPath.Required");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.SearchBase");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.ContainerName");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.Domain");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.DomainDistinguishedName");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapServerPort");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.UseSSL");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.UseSSL");
_localizationService.DeletePluginLocaleResource("Plugins.ExternalAuth.NovellActiveDirectory.LdapPassword.Required");
base.Uninstall();
}
}
}