Index: c2s/authreg_ldap.c
--- c2s/authreg_ldap.c.orig	2004-04-26 07:47:19 +0200
+++ c2s/authreg_ldap.c	2004-10-18 19:57:24 +0200
@@ -70,6 +70,24 @@
     return ld_errno;
 }
 
+/** entry-point function to be called when following referrals.
+    this forces a re-bind, since Active Directory required you to
+    re-bind this makes it work with M$ Windows AD.
+                  -- Juan F Arjona (jfarjona at jfarjona.com). */
+static int rebindProc(LDAP *ld, LDAP_CONST char *url, ber_tag_t request, ber_int_t msgid, void *mdata)
+{
+    moddata_t data = mdata;
+    data->ld = ld;
+    if (ldap_simple_bind_s(data->ld, data->binddn, data->bindpw)) {
+        log_write(data->ar->c2s->log, LOG_ERR, "ldap: bind failed(to %s): %s",
+                  url, ldap_err2string(_ldap_get_lderrno(data->ld)));
+        ldap_unbind_s(data->ld);
+        data->ld = NULL;
+        return NULL;
+    }
+    return LDAP_SUCCESS;
+}
+
 /** connect to the ldap host */
 static int _ldap_connect(moddata_t data)
 {
@@ -151,6 +169,14 @@
 
     snprintf(filter, 1024, "(%s=%s)", data->uidattr, username);
 
+    if (ldap_set_rebind_proc(data->ld, &rebindProc,data) ) {
+        log_write(data->ar->c2s->log, LOG_ERR, "ldap: set_rebind_proc failed: %s",
+                  ldap_err2string(_ldap_get_lderrno(data->ld)));
+        ldap_unbind_s(data->ld);
+        data->ld = NULL;
+        return NULL;
+    }
+
     if(ldap_search_s(data->ld, basedn, LDAP_SCOPE_SUBTREE, filter, no_attrs, 0, &result))
     {
         log_write(data->ar->c2s->log, LOG_ERR, "ldap: search %s failed: %s", filter, ldap_err2string(_ldap_get_lderrno(data->ld)));
Index: etc/c2s.xml.dist.in
--- etc/c2s.xml.dist.in.orig	2004-04-26 07:47:21 +0200
+++ etc/c2s.xml.dist.in	2004-10-18 19:57:24 +0200
@@ -46,18 +46,16 @@
   </router>
 
   <!-- Log configuration - type is "syslog", "file" or "stdout" -->
-  <log type='syslog'>
+  <log type='file'>
     <!-- If logging to syslog, this is the log ident -->
-    <ident>jabberd/c2s</ident>
+    <!-- <ident>jabberd/c2s</ident> -->
 
     <!-- If logging to syslog, this is the log facility
          (local0 - local7)                        [default: local3] -->
-    <facility>local3</facility>
+    <!-- <facility>local3</facility> -->
     
     <!-- If logging to file, this is the filename of the logfile -->
-    <!--
     <file>@localstatedir@/jabberd/log/c2s.log</file>
-    -->
   </log>
 
   <!-- Local network configuration -->
@@ -78,7 +76,7 @@
     <!-- <id realm='company'>localhost</id> -->
 
     <!-- IP address to bind to (default: 0.0.0.0) -->
-    <ip>0.0.0.0</ip>
+    <ip>127.0.0.1</ip>
 
     <!-- Port to bind to, or 0 to disable unencrypted access to the
          server (default: 5222) -->
@@ -206,7 +204,7 @@
   <!-- Authentication/registration database configuration -->
   <authreg>
     <!-- Backend module to use -->
-    <module>mysql</module>
+    <module>db</module>
 
     <!-- Registration configuration -->
     <register>
Index: etc/resolver.xml.dist.in
--- etc/resolver.xml.dist.in.orig	2003-10-30 00:30:06 +0100
+++ etc/resolver.xml.dist.in	2004-10-18 19:57:24 +0200
@@ -46,18 +46,16 @@
   </router>
 
   <!-- Log configuration - type is "syslog", "file" or "stdout" -->
-  <log type='syslog'>
+  <log type='file'>
     <!-- If logging to syslog, this is the log ident -->
-    <ident>jabberd/resolver</ident>
+    <!-- <ident>jabberd/resolver</ident> -->
 
     <!-- If logging to syslog, this is the log facility
          (local0 - local7)                        [default: local3] -->
-    <facility>local3</facility>
+    <!-- <facility>local3</facility> -->
 
     <!-- If logging to file, this is the filename of the logfile -->
-    <!--
     <file>@localstatedir@/jabberd/log/resolver.log</file>
-    -->
   </log>
 
   <!-- SRV records will be resolved in the following order. The first
Index: etc/router.xml.dist.in
--- etc/router.xml.dist.in.orig	2003-10-23 02:43:56 +0200
+++ etc/router.xml.dist.in	2004-10-18 19:57:24 +0200
@@ -9,24 +9,22 @@
   <pidfile>@localstatedir@/jabberd/pid/router.pid</pidfile>
 
   <!-- Log configuration - type is "syslog", "file" or "stdout" -->
-  <log type='syslog'>
+  <log type='file'>
     <!-- If logging to syslog, this is the log ident -->
-    <ident>jabberd/router</ident>
+    <!-- <ident>jabberd/router</ident> -->
 
     <!-- If logging to syslog, this is the log facility
          (local0 - local7)                        [default: local3] -->
-    <facility>local3</facility>
+    <!-- <facility>local3</facility> -->
 
     <!-- If logging to file, this is the filename of the logfile -->
-    <!--
     <file>@localstatedir@/jabberd/log/router.log</file>
-    -->
   </log>
 
   <!-- Local network configuration -->
   <local>
     <!-- IP address to bind to (default: 0.0.0.0) -->
-    <ip>0.0.0.0</ip>
+    <ip>127.0.0.1</ip>
 
     <!-- Port to bind to (default: 5347) -->
     <port>5347</port>
Index: etc/s2s.xml.dist.in
--- etc/s2s.xml.dist.in.orig	2004-04-25 12:28:29 +0200
+++ etc/s2s.xml.dist.in	2004-10-18 19:57:24 +0200
@@ -56,25 +56,23 @@
   </router>
 
   <!-- Log configuration - type is "syslog", "file" or "stdout" -->
-  <log type='syslog'>
+  <log type='file'>
     <!-- If logging to syslog, this is the log ident -->
-    <ident>jabberd/s2s</ident>
+    <!-- <ident>jabberd/s2s</ident> -->
 
     <!-- If logging to syslog, this is the log facility
          (local0 - local7)                        [default: local3] -->
-    <facility>local3</facility>
+    <!-- <facility>local3</facility> -->
 
     <!-- if logging to file, this is the filename of the logfile -->
-    <!--
     <file>@localstatedir@/jabberd/log/s2s.log</file>
-    -->
   </log>
 
   <!-- Local network configuration -->
   <local>
     <!-- IP and port to listen for incoming s2s connections on
                                            (default: 0.0.0.0, 5269) -->
-    <ip>0.0.0.0</ip>
+    <ip>127.0.0.1</ip>
     <port>5269</port>
 
     <!-- Helper DNS resolver component - if this component is not
Index: etc/sm.xml.dist.in
--- etc/sm.xml.dist.in.orig	2004-04-02 06:34:17 +0200
+++ etc/sm.xml.dist.in	2004-10-18 19:57:24 +0200
@@ -49,24 +49,22 @@
   </router>
 
   <!-- Log configuration - type is "syslog", "file" or "stdout" -->
-  <log type='syslog'>
+  <log type='file'>
     <!-- If logging to syslog, this is the log ident -->
-    <ident>jabberd/sm</ident>
+    <!-- <ident>jabberd/sm</ident> -->
 
     <!-- If logging to syslog, this is the log facility
          (local0 - local7)                        [default: local3] -->
-    <facility>local3</facility>
+    <!-- <facility>local3</facility> -->
 
     <!-- If logging to file, this is the filename of the logfile -->
-    <!--
     <file>@localstatedir@/jabberd/log/sm.log</file>
-    -->
   </log>
 
   <!-- Storage database configuration -->
   <storage>
     <!-- By default, we use the MySQL driver for all storage -->
-    <driver>mysql</driver>
+    <driver>db</driver>
 
     <!-- Its also possible to explicitly list alternate drivers for
          specific data types. -->
Index: sm/mod_roster.c
--- sm/mod_roster.c.orig	2004-10-05 06:34:10 +0200
+++ sm/mod_roster.c	2004-10-18 19:57:35 +0200
@@ -570,6 +570,9 @@
     /* We have to free old packet - Lemming's memory leak fix */
                pkt_free(pkt);
 
+    /* We have to free old packet - Lemming's memory leak fix */
+    pkt_free(pkt);
+
     /* build a new packet to push out to everyone */
     pkt = pkt_create(user->sm, "iq", "set", NULL, NULL);
     ns = nad_add_namespace(pkt->nad, uri_ROSTER, NULL);
Index: util/util.h
--- util/util.h.orig	2004-10-05 06:27:50 +0200
+++ util/util.h	2004-10-18 19:57:24 +0200
@@ -30,6 +30,8 @@
 #include <time.h>
 #include <errno.h>
 #include <assert.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 
 #ifdef HAVE_NETINET_IN_H
 # include <netinet/in.h>
