]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_ldapoper.cpp
Attach to events and register services in init()
[user/henk/code/inspircd.git] / src / modules / extra / m_ldapoper.cpp
index 6bd834dc80541f13c3b6f12233628236f8f2020c..e8455529d617ba669a06b946d116d80e70b4a86a 100644 (file)
 
 #include <ldap.h>
 
-#ifdef WINDOWS
+#ifdef _WIN32
 # pragma comment(lib, "ldap.lib")
 # pragma comment(lib, "lber.lib")
 #endif
 
-/* $ModDesc: Allow/Deny connections based upon answer from LDAP server */
+/* $ModDesc: Adds the ability to authenticate opers via LDAP */
 /* $LinkerFlags: -lldap */
 
 class ModuleLDAPAuth : public Module
@@ -45,8 +45,8 @@ class ModuleLDAPAuth : public Module
        LDAP *conn;
 
 public:
-       ModuleLDAPAuth()
-               {
+       void init()
+       {
                conn = NULL;
                Implementation eventlist[] = { I_OnRehash, I_OnPassCompare };
                ServerInstance->Modules->Attach(eventlist, this, 2);
@@ -61,13 +61,13 @@ public:
 
        virtual void OnRehash(User* user)
        {
-               ConfigReader Conf;
+               ConfigTag* tag = ServerInstance->Config->ConfValue("ldapoper");
 
-               base                    = Conf.ReadValue("ldapoper", "baserdn", 0);
-               ldapserver              = Conf.ReadValue("ldapoper", "server", 0);
-               std::string scope       = Conf.ReadValue("ldapoper", "searchscope", 0);
-               username                = Conf.ReadValue("ldapoper", "binddn", 0);
-               password                = Conf.ReadValue("ldapoper", "bindauth", 0);
+               base                    = tag->getString("baserdn");
+               ldapserver              = tag->getString("server");
+               std::string scope       = tag->getString("searchscope");
+               username                = tag->getString("binddn");
+               password                = tag->getString("bindaut");
 
                if (scope == "base")
                        searchscope = LDAP_SCOPE_BASE;
@@ -181,7 +181,7 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version("Allow/Deny connections based upon answer from LDAP server", VF_VENDOR);
+               return Version("Adds the ability to authenticate opers via LDAP", VF_VENDOR);
        }
 
 };