*/
/*
- * locate using DNS SRV records. Location code based on
- * MIT Kerberos KDC location code.
+ * locate LDAP servers using DNS SRV records.
+ * Location code based on MIT Kerberos KDC location code.
*/
#include "portable.h"
#define T_SRV 33
#endif /* T_SRV */
-int ldap_pvt_domain2dn(LDAP_CONST char *domain_in, char **dnp)
+int ldap_dn2domain(
+ LDAP_CONST char *dn_in,
+ char **domainp)
+{
+ /* not yet implemented */
+ return LDAP_NOT_SUPPORTED;
+}
+
+int ldap_domain2dn(
+ LDAP_CONST char *domain_in,
+ char **dnp)
{
char *domain, *s, *tok_r, *dn;
size_t loc;
s = ldap_pvt_strtok(NULL, ".", &tok_r)) {
size_t len = strlen(s);
- dn = (char *) LDAP_REALLOC(dn, loc + len + 4);
+ dn = (char *) LDAP_REALLOC(dn, loc + sizeof(",dc=") + len );
if (dn == NULL) {
LDAP_FREE(domain);
return LDAP_NO_MEMORY;
loc++;
}
strcpy(dn + loc, "dc=");
- loc += 3;
+ loc += sizeof("dc=")-1;
strcpy(dn + loc, s);
loc += len;
}
/*
- * Lookup LDAP servers for domain (using the DNS
- * SRV record _ldap._tcp.domain), set the default
- * base using an algorithmic mapping of the domain,
- * and return a session.
+ * Lookup and return LDAP servers for domain (using the DNS
+ * SRV record _ldap._tcp.domain).
*/
-int ldap_dnssrv_init(LDAP ** ldp, LDAP_CONST char *domain)
+int ldap_domain2hostlist(
+ LDAP_CONST char *domain,
+ char **list )
{
#ifdef HAVE_RES_SEARCH
char *request;
char *dn;
char *hostlist = NULL;
- LDAP *ld = NULL;
int rc, len, cur = 0;
unsigned char reply[1024];
+ if( domain == NULL || *domain == '\0' ) {
+ return LDAP_PARAM_ERROR;
+ }
+
+ if( list == NULL ) {
+ return LDAP_PARAM_ERROR;
+ }
+
request = LDAP_MALLOC(strlen(domain) + sizeof("_ldap._tcp."));
if (request == NULL) {
rc = LDAP_NO_MEMORY;
char host[1024];
int status;
u_short port;
- int priority, weight;
+ /* int priority, weight; */
/* Parse out query */
p = reply;
if (status < 0) {
goto out;
}
- priority = (p[0] << 8) | p[1];
- weight = (p[2] << 8) | p[3];
+ /* ignore priority and weight for now */
+ /* priority = (p[0] << 8) | p[1]; */
+ /* weight = (p[2] << 8) | p[3]; */
port = (p[4] << 8) | p[5];
- buflen = strlen(host) + /* :XXXXX\0 */ 7;
+ buflen = strlen(host) + sizeof(":65355");
hostlist = (char *) LDAP_REALLOC(hostlist, cur + buflen);
if (hostlist == NULL) {
rc = LDAP_NO_MEMORY;
rc = LDAP_UNAVAILABLE;
goto out;
}
- rc = ldap_create(&ld);
- if (rc != LDAP_SUCCESS) {
- goto out;
- }
- rc = ldap_set_option(ld, LDAP_OPT_HOST_NAME, hostlist);
- if (rc != LDAP_SUCCESS) {
- goto out;
- }
- rc = ldap_pvt_domain2dn(domain, &dn);
- if (rc != LDAP_SUCCESS) {
- goto out;
- }
- if (ld->ld_options.ldo_defbase != NULL) {
- LDAP_FREE(ld->ld_options.ldo_defbase);
- }
- ld->ld_options.ldo_defbase = dn;
-
- *ldp = ld;
rc = LDAP_SUCCESS;
+ *list = hostlist;
out:
#ifdef LDAP_R_COMPILE
if (request != NULL) {
LDAP_FREE(request);
}
- if (hostlist != NULL) {
+ if (rc != LDAP_SUCCESS && hostlist != NULL) {
LDAP_FREE(hostlist);
}
- if (rc != LDAP_SUCCESS && ld != NULL) {
- ldap_ld_free(ld, 1, NULL, NULL);
- }
return rc;
#else
return LDAP_NOT_SUPPORTED;
# PROP Output_Dir "..\..\Release"
# PROP Intermediate_Dir "..\..\Release\libldap"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_WINDOWS" /YX /FD /c
BSC32=bscmake.exe
# PROP Output_Dir "..\..\Debug"
# PROP Intermediate_Dir "..\..\Debug\libldap"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
BSC32=bscmake.exe
# PROP Output_Dir "..\..\SDebug"
# PROP Intermediate_Dir "..\..\SDebug\libldap"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
BSC32=bscmake.exe
# PROP Output_Dir "..\..\SRelease"
# PROP Intermediate_Dir "..\..\SRelease\libldap"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_WINDOWS" /YX /FD /c
BSC32=bscmake.exe
# End Source File
# Begin Source File
+SOURCE=.\dnssrv.c
+# End Source File
+# Begin Source File
+
SOURCE=.\dsparse.c
# End Source File
# Begin Source File
# PROP Output_Dir "..\..\Release"
# PROP Intermediate_Dir "..\..\Release\libldap_r"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "LDAP_R_COMPILE" /D "WIN32" /D "_WINDOWS" /D _WIN32_WINNT=0x0400 /YX /FD /c
BSC32=bscmake.exe
# PROP Output_Dir "..\..\Debug"
# PROP Intermediate_Dir "..\..\Debug\libldap_r"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\..\include" /D "_DEBUG" /D "LDAP_R_COMPILE" /D "WIN32" /D "_WINDOWS" /D _WIN32_WINNT=0x0400 /FR /YX /FD /c
BSC32=bscmake.exe
# PROP Output_Dir "..\..\SDebug"
# PROP Intermediate_Dir "..\..\SDebug\libldap_r"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /MTd /W3 /GX /Z7 /Od /I "..\..\include" /D "_DEBUG" /D "LDAP_R_COMPILE" /D "WIN32" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /Z7 /Od /I "..\..\include" /D "_DEBUG" /D "LDAP_R_COMPILE" /D "WIN32" /D "_WINDOWS" /FR /YX /FD /c
BSC32=bscmake.exe
# PROP Output_Dir "..\..\SRelease"
# PROP Intermediate_Dir "..\..\SRelease\libldap_r"
# PROP Target_Dir ""
+RSC=rc.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "NDEBUG" /D "LDAP_R_COMPILE" /D "WIN32" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "LDAP_R_COMPILE" /D "WIN32" /D "_WINDOWS" /YX /FD /c
BSC32=bscmake.exe
# End Source File
# Begin Source File
+SOURCE=..\libldap\dnssrv.c
+# End Source File
+# Begin Source File
+
SOURCE=..\libldap\dsparse.c
# End Source File
# Begin Source File