e55890
diff --git a/bin/sdb_tools/Makefile.in b/bin/sdb_tools/Makefile.in
e55890
index 95ab742..6069f09 100644
e55890
--- a/bin/sdb_tools/Makefile.in
e55890
+++ b/bin/sdb_tools/Makefile.in
e55890
@@ -32,11 +32,11 @@ DEPLIBS =	${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
e55890
 LIBS =		${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
e55890
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} ${DBDRIVER_LIBS} @LIBS@
e55890
 
e55890
-TARGETS =	zone2ldap@EXEEXT@ zonetodb@EXEEXT@ zone2sqlite@EXEEXT@
e55890
+TARGETS =	zone2ldap@EXEEXT@ ldap2zone@EXEEXT@ zonetodb@EXEEXT@ zone2sqlite@EXEEXT@
e55890
 
e55890
-OBJS	=	zone2ldap.@O@ zonetodb.@O@ zone2sqlite.@O@
e55890
+OBJS	=	zone2ldap.@O@ ldap2zone.@O@ zonetodb.@O@ zone2sqlite.@O@
e55890
 
e55890
-SRCS    =       zone2ldap.c zonetodb.c zone2sqlite.c
e55890
+SRCS    =       zone2ldap.c ldap2zone.c zonetodb.c zone2sqlite.c
e55890
 
e55890
 MANPAGES =      zone2ldap.1
e55890
 
e55890
@@ -53,6 +53,9 @@ zonetodb@EXEEXT@: zonetodb.@O@  ${DEPLIBS}
e55890
 zone2sqlite@EXEEXT@: zone2sqlite.@O@  ${DEPLIBS}
e55890
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o $@ zone2sqlite.@O@ -lsqlite3 -lssl ${LIBS}
e55890
 
e55890
+ldap2zone@EXEEXT@: ldap2zone.@O@ ${DEPLIBS}
e55890
+	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o $@ ldap2zone.@O@ -lldap -llber ${LIBS}
e55890
+
e55890
 clean distclean manclean maintainer-clean::
e55890
 	rm -f ${TARGETS} ${OBJS}
e55890
 
e55890
@@ -62,6 +65,7 @@ installdirs:
e55890
 
e55890
 install:: ${TARGETS} installdirs
e55890
 	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zone2ldap@EXEEXT@ ${DESTDIR}${sbindir}
e55890
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} ldap2zone@EXEEXT@ ${DESTDIR}${sbindir}
e55890
 	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zonetodb@EXEEXT@  ${DESTDIR}${sbindir}
e55890
 	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zone2sqlite@EXEEXT@ ${DESTDIR}${sbindir}
e55890
 	${INSTALL_DATA} ${srcdir}/zone2ldap.1 ${DESTDIR}${mandir}/man1/zone2ldap.1
e55890
diff --git a/bin/sdb_tools/zone2ldap.c b/bin/sdb_tools/zone2ldap.c
27025e
index aa2c711..76186b5 100644
e55890
--- a/bin/sdb_tools/zone2ldap.c
e55890
+++ b/bin/sdb_tools/zone2ldap.c
27025e
@@ -66,6 +66,9 @@ ldap_info;
e55890
 /* usage Info */
e55890
 void usage (void);
e55890
 
e55890
+/* Check for existence of (and possibly add) containing dNSZone objects */
e55890
+int lookup_dns_zones( ldap_info *ldinfo);
e55890
+
e55890
 /* Add to the ldap dit */
e55890
 void add_ldap_values (ldap_info * ldinfo);
e55890
 
27025e
@@ -82,7 +85,7 @@ char **hostname_to_dn_list (char *hostname, char *zone, unsigned int flags);
e55890
 int get_attr_list_size (char **tmp);
e55890
 
e55890
 /* Get a DN */
e55890
-char *build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag);
e55890
+char *build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag, char *zone);
e55890
 
e55890
 /* Add to RR list */
e55890
 void add_to_rr_list (char *dn, char *name, char *type, char *data,
27025e
@@ -104,11 +107,27 @@ void
e55890
 init_ldap_conn ();
e55890
 void usage();
e55890
 
e55890
-char *argzone, *ldapbase, *binddn, *bindpw = NULL;
e55890
-const char *ldapsystem = "localhost";
e55890
-static const char *objectClasses[] =
e55890
-  { "top", "dNSZone", NULL };
e55890
-static const char *topObjectClasses[] = { "top", NULL };
e55890
+static char *argzone, *ldapbase, *binddn, *bindpw = NULL;
e55890
+
e55890
+/* these are needed to placate gcc4's const-ness const-ernations : */
e55890
+static char localhost[] = "localhost";
e55890
+static char *ldapsystem=&(localhost[0]);
e55890
+/* dnszone schema class names: */
e55890
+static char topClass    [] ="top";
e55890
+static char dNSZoneClass[] ="dNSZone";
e55890
+static char objectClass [] ="objectClass";
e55890
+static char dcObjectClass[]="dcObject";
e55890
+/* dnszone schema attribute names: */
e55890
+static char relativeDomainName[]="relativeDomainName";
e55890
+static char dNSTTL            []="dNSTTL";
e55890
+static char zoneName          []="zoneName";
e55890
+static char dc                []="dc";
e55890
+static char sameZone          []="@";
e55890
+/* LDAPMod mod_values: */
e55890
+static char *objectClasses    []= { &(topClass[0]), &(dNSZoneClass[0]), NULL };
e55890
+static char *topObjectClasses []= { &(topClass[0]), &(dcObjectClass[0]), &(dNSZoneClass[0]), NULL };
e55890
+static char *dn_buffer      [64]={NULL};
e55890
+
e55890
 LDAP *conn;
e55890
 unsigned int debug = 0;
e55890
 
27025e
@@ -132,12 +151,12 @@ main (int argc, char **argv)
e55890
   isc_result_t result;
e55890
   char *basedn;
e55890
   ldap_info *tmp;
e55890
-  LDAPMod *base_attrs[2];
e55890
-  LDAPMod base;
e55890
+  LDAPMod *base_attrs[5];
e55890
+  LDAPMod base, dcBase, znBase, rdnBase;
e55890
   isc_buffer_t buff;
e55890
   char *zonefile=0L;
e55890
   char fullbasedn[1024];
e55890
-  char *ctmp;
e55890
+  char *ctmp, *zn, *dcp[2], *znp[2], *rdn[2];
e55890
   dns_fixedname_t fixedzone, fixedname;
e55890
   dns_rdataset_t rdataset;
e55890
   char **dc_list;
27025e
@@ -150,7 +169,7 @@ main (int argc, char **argv)
e55890
   extern char *optarg;
e55890
   extern int optind, opterr, optopt;
e55890
   int create_base = 0;
e55890
-  int topt;
e55890
+  int topt, dcn, zdn, znlen;
e55890
 
e55890
   if (argc < 2)
e55890
     {
27025e
@@ -158,7 +177,7 @@ main (int argc, char **argv)
e55890
       exit (-1);
e55890
     }
e55890
 
e55890
-  while ((topt = getopt (argc, argv, "D:w:b:z:f:h:?dcv")) != -1)
e55890
+  while ((topt = getopt (argc, argv, "D:Ww:b:z:f:h:?dcv")) != -1)
e55890
     {
e55890
       switch (topt)
e55890
 	{
27025e
@@ -181,6 +200,9 @@ main (int argc, char **argv)
e55890
 	  if (bindpw == NULL)
e55890
 	    fatal("strdup");
e55890
 	  break;
e55890
+	case 'W':
e55890
+	  bindpw = getpass("Enter LDAP Password: ");
e55890
+	  break;
e55890
 	case 'b':
e55890
 	  ldapbase = strdup (optarg);
e55890
 	  if (ldapbase == NULL)
27025e
@@ -300,27 +322,62 @@ main (int argc, char **argv)
e55890
     {
e55890
       if (debug)
e55890
 	printf ("Creating base zone DN %s\n", argzone);
e55890
-
e55890
+      
e55890
       dc_list = hostname_to_dn_list (argzone, argzone, DNS_TOP);
e55890
-      basedn = build_dn_from_dc_list (dc_list, 0, NO_SPEC);
e55890
 
e55890
-      for (ctmp = &basedn[strlen (basedn)]; ctmp >= &basedn[0]; ctmp--)
e55890
+      basedn = build_dn_from_dc_list (dc_list, 0, NO_SPEC, argzone);
e55890
+      if (debug)
e55890
+	printf ("base DN %s\n", basedn);
e55890
+
e55890
+      for (ctmp = &basedn[strlen (basedn)], dcn=0; ctmp >= &basedn[0]; ctmp--)
e55890
 	{
e55890
-	  if ((*ctmp == ',') || (ctmp == &basedn[0]))
e55890
+	    if ((*ctmp == ',') || (ctmp == &basedn[0]))
e55890
 	    {
e55890
+
e55890
 	      base.mod_op = LDAP_MOD_ADD;
e55890
-	      base.mod_type = (char*)"objectClass";
e55890
-	      base.mod_values = (char**)topObjectClasses;
e55890
+	      base.mod_type = objectClass;
e55890
+	      base.mod_values = topObjectClasses;
e55890
 	      base_attrs[0] = (void*)&bas;;
e55890
-	      base_attrs[1] = NULL;
e55890
-
e55890
+	     
e55890
+	      dcBase.mod_op = LDAP_MOD_ADD;
e55890
+	      dcBase.mod_type = dc;
e55890
+	      dcp[0]=dc_list[dcn];
e55890
+	      dcp[1]=0L;
e55890
+	      dcBase.mod_values=dcp;
e55890
+	      base_attrs[1] = (void*)&dcBase;
e55890
+
e55890
+	      znBase.mod_op = LDAP_MOD_ADD;
e55890
+	      znBase.mod_type = zoneName;	      
e55890
+	      for( zdn = dcn, znlen = 0; zdn >= 0; zdn-- )
e55890
+		  znlen += strlen(dc_list[zdn])+1;
e55890
+	      znp[0] = (char*)malloc(znlen+1);
e55890
+	      znp[1] = 0L;
e55890
+	      for( zdn = dcn, zn=znp[0]; zdn >= 0; zdn-- )		  
e55890
+		  zn+=sprintf(zn,"%s%s",dc_list[zdn], 
e55890
+			      ((zdn > 0) && (*(dc_list[zdn-1])!='.')) ? "." : ""
e55890
+		             );
e55890
+
e55890
+	      znBase.mod_values = znp;
e55890
+	      base_attrs[2] = (void*)&znBase;
e55890
+
e55890
+	      rdnBase.mod_op = LDAP_MOD_ADD;
e55890
+	      rdnBase.mod_type = relativeDomainName;
e55890
+	      rdn[0] = strdup(sameZone);
e55890
+	      rdn[1] = 0L;
e55890
+	      rdnBase.mod_values = rdn;
e55890
+	      base_attrs[3] = (void*)&rdnBase;
e55890
+	      
e55890
+	      dcn++;
e55890
+
e55890
+	      base.mod_values = topObjectClasses;
e55890
+	      base_attrs[4] = NULL;	      
e55890
+	      
e55890
 	      if (ldapbase)
e55890
 		{
e55890
 		  if (ctmp != &basedn[0])
e55890
 		    sprintf (fullbasedn, "%s,%s", ctmp + 1, ldapbase);
e55890
 		  else
e55890
-		    sprintf (fullbasedn, "%s,%s", ctmp, ldapbase);
e55890
-
e55890
+		    sprintf (fullbasedn, "%s,%s", ctmp, ldapbase);		  
e55890
 		}
e55890
 	      else
e55890
 		{
27025e
@@ -329,8 +386,13 @@ main (int argc, char **argv)
e55890
 		  else
e55890
 		    sprintf (fullbasedn, "%s", ctmp);
e55890
 		}
e55890
+
e55890
+	      if( debug )
e55890
+		  printf("Full base dn: %s\n", fullbasedn);
e55890
+
e55890
 	      result = ldap_add_s (conn, fullbasedn, base_attrs);
e55890
 	      ldap_result_check ("intial ldap_add_s", fullbasedn, result);
e55890
+
e55890
 	    }
e55890
 
e55890
 	}
27025e
@@ -408,14 +470,14 @@ generate_ldap (dns_name_t * dnsname, dns_rdata_t * rdata, unsigned int ttl)
e55890
   isc_result_check (result, "dns_rdata_totext");
e55890
   data[isc_buffer_usedlength (&buff)] = 0;
e55890
 
e55890
-  dc_list = hostname_to_dn_list (name, argzone, DNS_OBJECT);
e55890
+  dc_list = hostname_to_dn_list ((char*)name, argzone, DNS_OBJECT);
e55890
   len = (get_attr_list_size (dc_list) - 2);
e55890
-  dn = build_dn_from_dc_list (dc_list, ttl, WI_SPEC);
e55890
+  dn = build_dn_from_dc_list (dc_list, ttl, WI_SPEC, argzone);
e55890
 
e55890
   if (debug)
e55890
     printf ("Adding %s (%s %s) to run queue list.\n", dn, type, data);
e55890
 
e55890
-  add_to_rr_list (dn, dc_list[len], type, data, ttl, DNS_OBJECT);
e55890
+  add_to_rr_list (dn, dc_list[len], (char*)type, (char*)data, ttl, DNS_OBJECT);
e55890
 }
e55890
 
e55890
 
27025e
@@ -455,7 +517,8 @@ add_to_rr_list (char *dn, char *name, char *type,
e55890
   int attrlist;
e55890
   char ldap_type_buffer[128];
e55890
   char charttl[64];
e55890
-
e55890
+  char *zn;
e55890
+  int znlen;
e55890
 
e55890
   if ((tmp = locate_by_dn (dn)) == NULL)
e55890
     {
27025e
@@ -482,13 +545,13 @@ add_to_rr_list (char *dn, char *name, char *type,
e55890
 	    fatal("malloc");
e55890
 	}
e55890
       tmp->attrs[0]->mod_op = LDAP_MOD_ADD;
e55890
-      tmp->attrs[0]->mod_type = (char*)"objectClass";
e55890
+      tmp->attrs[0]->mod_type = objectClass;
e55890
 
e55890
       if (flags == DNS_OBJECT)
e55890
-	tmp->attrs[0]->mod_values = (char**)objectClasses;
e55890
+	tmp->attrs[0]->mod_values = objectClasses;
e55890
       else
e55890
 	{
e55890
-	  tmp->attrs[0]->mod_values = (char**)topObjectClasses;
e55890
+	  tmp->attrs[0]->mod_values =topObjectClasses;
e55890
 	  tmp->attrs[1] = NULL;
e55890
 	  tmp->attrcnt = 2;
e55890
 	  tmp->next = ldap_info_base;
27025e
@@ -497,7 +560,7 @@ add_to_rr_list (char *dn, char *name, char *type,
e55890
 	}
e55890
 
e55890
       tmp->attrs[1]->mod_op = LDAP_MOD_ADD;
e55890
-      tmp->attrs[1]->mod_type = (char*)"relativeDomainName";
e55890
+      tmp->attrs[1]->mod_type = relativeDomainName;
e55890
       tmp->attrs[1]->mod_values = (char **) calloc (sizeof (char *), 2);
e55890
 
e55890
       if (tmp->attrs[1]->mod_values == (char **)NULL)
27025e
@@ -526,7 +589,7 @@ add_to_rr_list (char *dn, char *name, char *type,
e55890
 	 fatal("strdup");
e55890
 
e55890
       tmp->attrs[3]->mod_op = LDAP_MOD_ADD;
e55890
-      tmp->attrs[3]->mod_type = (char*)"dNSTTL";
e55890
+      tmp->attrs[3]->mod_type = dNSTTL;
e55890
       tmp->attrs[3]->mod_values = (char **) calloc (sizeof (char *), 2);
e55890
 
e55890
       if (tmp->attrs[3]->mod_values == (char **)NULL)
27025e
@@ -539,14 +602,25 @@ add_to_rr_list (char *dn, char *name, char *type,
e55890
       if (tmp->attrs[3]->mod_values[0] == NULL)
e55890
 	 fatal("strdup");
e55890
 
e55890
+      znlen=strlen(gbl_zone);      
e55890
+      if ( *(gbl_zone + (znlen-1)) == '.' )
e55890
+      { /* ldapdb MUST search by relative zone name */
e55890
+	  zn = (char*)malloc(znlen);
e55890
+	  strncpy(zn,gbl_zone,znlen-1);
e55890
+	  *(zn + (znlen-1))='\0';	  
e55890
+      }else
e55890
+      {
e55890
+	  zn = gbl_zone;
e55890
+      }
e55890
+
e55890
       tmp->attrs[4]->mod_op = LDAP_MOD_ADD;
e55890
-      tmp->attrs[4]->mod_type = (char*)"zoneName";
e55890
+      tmp->attrs[4]->mod_type = zoneName;
e55890
       tmp->attrs[4]->mod_values = (char **)calloc(sizeof(char *), 2);
e55890
 
e55890
       if (tmp->attrs[4]->mod_values == (char **)NULL)
e55890
 	 fatal("calloc");
e55890
 
e55890
-      tmp->attrs[4]->mod_values[0] = gbl_zone;
e55890
+      tmp->attrs[4]->mod_values[0] = zn;
e55890
       tmp->attrs[4]->mod_values[1] = NULL;
e55890
 
e55890
       tmp->attrs[5] = NULL;
27025e
@@ -557,7 +631,7 @@ add_to_rr_list (char *dn, char *name, char *type,
e55890
   else
e55890
     {
e55890
 
e55890
-      for (i = 0; tmp->attrs[i] != NULL; i++)
e55890
+	for (i = 0; tmp->attrs[i] != NULL; i++)
e55890
 	{
e55890
 	  sprintf (ldap_type_buffer, "%sRecord", type);
e55890
 	  if (!strncmp
27025e
@@ -631,44 +705,70 @@ char **
e55890
 hostname_to_dn_list (char *hostname, char *zone, unsigned int flags)
e55890
 {
e55890
   char *tmp;
e55890
-  static char *dn_buffer[64];
e55890
   int i = 0;
e55890
-  char *zname;
e55890
-  char *hnamebuff;
e55890
-
e55890
-  zname = strdup (hostname);
e55890
-  if (zname == NULL)
e55890
-	fatal("strdup");
e55890
-
e55890
-  if (flags == DNS_OBJECT)
e55890
-    {
e55890
-
e55890
-      if (strlen (zname) != strlen (zone))
e55890
-	{
e55890
-	  tmp = &zname[strlen (zname) - strlen (zone)];
e55890
-	  *--tmp = '\0';
e55890
-	  hnamebuff = strdup (zname);
e55890
-	  if (hnamebuff == NULL)
e55890
-		fatal("strdup");
e55890
-	  zname = ++tmp;
e55890
-	}
e55890
-      else
e55890
-	hnamebuff = (char*)"@";
e55890
-    }
e55890
-  else
e55890
-    {
e55890
-      zname = zone;
e55890
-      hnamebuff = NULL;
e55890
-    }
e55890
-
e55890
-  for (tmp = strrchr (zname, '.'); tmp != (char *) 0;
e55890
-       tmp = strrchr (zname, '.'))
e55890
-    {
e55890
-      *tmp++ = '\0';
e55890
-      dn_buffer[i++] = tmp;
e55890
-    }
e55890
-  dn_buffer[i++] = zname;
e55890
-  dn_buffer[i++] = hnamebuff;
e55890
+  char *hname=0L, *last=0L;
e55890
+  int hlen=strlen(hostname), zlen=(strlen(zone));
e55890
+
e55890
+/*  printf("hostname: %s zone: %s\n",hostname, zone); */
e55890
+  hname=0L;
e55890
+  if(flags == DNS_OBJECT)
e55890
+  {
e55890
+      if( (zone[ zlen - 1 ] == '.') && (hostname[hlen - 1] != '.') )
e55890
+      {
e55890
+	  hname=(char*)malloc(hlen + 1);
e55890
+	  hlen += 1;
e55890
+	  sprintf(hname, "%s.", hostname);
e55890
+	  hostname = hname;
e55890
+      }
e55890
+      if(strcmp(hostname, zone) == 0)
e55890
+      {
e55890
+	  if( hname == 0 )
e55890
+	      hname=strdup(hostname);
e55890
+  	  last = strdup(sameZone);
e55890
+      }else
e55890
+      {	   
e55890
+	  if(  (hlen < zlen) 
e55890
+	     ||( strcmp( hostname + (hlen - zlen), zone ) != 0)
e55890
+	    )
e55890
+	  {
e55890
+	      if( hname != 0 )
e55890
+		  free(hname);
e55890
+	      hname=(char*)malloc( hlen + zlen + 1);
e55890
+	      if( *zone == '.' )
e55890
+		  sprintf(hname, "%s%s", hostname, zone);
e55890
+	      else
e55890
+		  sprintf(hname,"%s",zone);
e55890
+	  }else
e55890
+	  {
e55890
+	      if( hname == 0 )
e55890
+		  hname = strdup(hostname);
e55890
+	  }
e55890
+	  last = hname;
e55890
+      }
e55890
+  }else
e55890
+  { /* flags == DNS_TOP */
e55890
+      hname = strdup(zone);
e55890
+      last = hname;
e55890
+  }
e55890
+
e55890
+  for (tmp = strrchr (hname, '.'); tmp != (char *) 0;
e55890
+       tmp = strrchr (hname, '.'))
e55890
+  {
e55890
+      if( *( tmp + 1 ) != '\0' )
e55890
+      {
e55890
+	  *tmp = '\0';
e55890
+	  dn_buffer[i++] = ++tmp;
e55890
+      }else
e55890
+      { /* trailing '.' ! */
e55890
+	  dn_buffer[i++] = strdup(".");
e55890
+	  *tmp = '\0';
e55890
+	  if( tmp == hname )
e55890
+	      break;
e55890
+      }	  
e55890
+  }
e55890
+  if( ( last != hname ) && (tmp != hname) )
e55890
+      dn_buffer[i++] = hname;
e55890
+  dn_buffer[i++] = last;
e55890
   dn_buffer[i] = NULL;
e55890
 
e55890
   return dn_buffer;
27025e
@@ -680,24 +780,32 @@ hostname_to_dn_list (char *hostname, char *zone, unsigned int flags)
e55890
  * exception of "@"/SOA. */
e55890
 
e55890
 char *
e55890
-build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag)
e55890
+build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag, char *zone)
e55890
 {
e55890
   int size;
e55890
-  int x;
e55890
+  int x, znlen;
e55890
   static char dn[1024];
e55890
   char tmp[128];
e55890
+  char zn[DNS_NAME_MAXTEXT+1];
e55890
 
e55890
   bzero (tmp, sizeof (tmp));
e55890
   bzero (dn, sizeof (dn));
e55890
   size = get_attr_list_size (dc_list);
e55890
+  znlen = strlen(zone);
e55890
+  if ( *(zone + (znlen-1)) == '.' )
e55890
+  { /* ldapdb MUST search by relative zone name */
e55890
+      memcpy(&(zn[0]),zone,znlen-1);
e55890
+      *(zn + (znlen-1))='\0';
e55890
+      zone = zn;
e55890
+  }
e55890
   for (x = size - 2; x > 0; x--)
e55890
     {
e55890
     if (flag == WI_SPEC)
e55890
     {
e55890
       if (x == (size - 2) && (strncmp (dc_list[x], "@", 1) == 0) && (ttl))
27025e
-	sprintf (tmp, "relativeDomainName=%s + dNSTTL=%u,", dc_list[x], ttl);
e55890
+	sprintf (tmp, "zoneName=%s + relativeDomainName=%s,", zone, dc_list[x]);
e55890
       else if (x == (size - 2))
e55890
-	      sprintf(tmp, "relativeDomainName=%s,",dc_list[x]);
e55890
+	      sprintf(tmp, "zoneName=%s + relativeDomainName=%s,", zone, dc_list[x]);
e55890
       else
e55890
 	      sprintf(tmp,"dc=%s,", dc_list[x]);
e55890
     }
27025e
@@ -723,6 +831,7 @@ void
e55890
 init_ldap_conn ()
e55890
 {
e55890
   int result;
e55890
+  char ldb_tag[]="LDAP Bind";
e55890
   conn = ldap_open (ldapsystem, LDAP_PORT);
e55890
   if (conn == NULL)
e55890
     {
27025e
@@ -732,7 +841,7 @@ init_ldap_conn ()
e55890
     }
e55890
 
e55890
   result = ldap_simple_bind_s (conn, binddn, bindpw);
e55890
-  ldap_result_check ("ldap_simple_bind_s", (char*)"LDAP Bind", result);
e55890
+  ldap_result_check ("ldap_simple_bind_s", ldb_tag , result);
e55890
 }
e55890
 
e55890
 /* Like isc_result_check, only for LDAP */
27025e
@@ -749,8 +858,6 @@ ldap_result_check (const char *msg, char *dn, int err)
e55890
     }
e55890
 }
e55890
 
e55890
-
e55890
-
e55890
 /* For running the ldap_info run queue. */
e55890
 void
e55890
 add_ldap_values (ldap_info * ldinfo)
27025e
@@ -758,14 +865,14 @@ add_ldap_values (ldap_info * ldinfo)
e55890
   int result;
e55890
   char dnbuffer[1024];
e55890
 
e55890
-
e55890
   if (ldapbase != NULL)
e55890
     sprintf (dnbuffer, "%s,%s", ldinfo->dn, ldapbase);
e55890
   else
e55890
     sprintf (dnbuffer, "%s", ldinfo->dn);
e55890
 
e55890
   result = ldap_add_s (conn, dnbuffer, ldinfo->attrs);
e55890
-  ldap_result_check ("ldap_add_s", dnbuffer, result);
e55890
+    ldap_result_check ("ldap_add_s", dnbuffer, result);
e55890
+
e55890
 }
e55890
 
e55890
 
27025e
@@ -776,5 +883,5 @@ void
e55890
 usage ()
e55890
 {
e55890
   fprintf (stderr,
e55890
-	   "zone2ldap -D [BIND DN] -w [BIND PASSWORD] -b [BASE DN] -z [ZONE] -f [ZONE FILE] -h [LDAP HOST] "
e55890
+	   "zone2ldap -D [BIND DN] [-w BIND PASSWORD | -W:prompt] -b [BASE DN] -z [ZONE] -f [ZONE FILE] -h [LDAP HOST] "
e55890
 	   "[-c Create LDAP Base structure][-d Debug Output (lots !)] \n ");}