This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
len = (numbits+1)*(strlen(field)+1) + strlen(r) + 1;
- ret = SMB_MALLOC(len);
+ ret = (char *)SMB_MALLOC(len);
if (!ret)
return NULL;
strlcpy(ret,field, len);
p=strtok(r,sep);
- strlcat(ret, p, len);
-
- while ((p=strtok(NULL,sep))) {
- char *s;
- if (reverse)
- asprintf(&s, "%s%s,%s", field, p, ret);
- else
- asprintf(&s, "%s,%s%s", ret, field, p);
- free(ret);
- ret = s;
+ if (p) {
+ strlcat(ret, p, len);
+
+ while ((p=strtok(NULL,sep))) {
+ char *s;
+ if (reverse)
+ asprintf(&s, "%s%s,%s", field, p, ret);
+ else
+ asprintf(&s, "%s,%s%s", ret, field, p);
+ free(ret);
+ ret = s;
+ }
}
free(r);
return ads_build_path(realm, ".", "dc=", 0);
}
+/* return a DNS name in the for aa.bb.cc from the DN
+ "dc=AA,dc=BB,dc=CC". caller must free
+*/
+char *ads_build_domain(const char *dn)
+{
+ char *dnsdomain = NULL;
+
+ /* result should always be shorter than the DN */
+
+ if ( (dnsdomain = SMB_STRDUP( dn )) == NULL ) {
+ DEBUG(0,("ads_build_domain: malloc() failed!\n"));
+ return NULL;
+ }
+
+ strlower_m( dnsdomain );
+ all_string_sub( dnsdomain, "dc=", "", 0);
+ all_string_sub( dnsdomain, ",", ".", 0 );
+
+ return dnsdomain;
+}
+
+
#ifndef LDAP_PORT
#define LDAP_PORT 389
is_mine = (*ads)->is_mine;
#if HAVE_LDAP
- if ((*ads)->ld) ldap_unbind((*ads)->ld);
+ if ((*ads)->ld) {
+ ldap_unbind((*ads)->ld);
+ }
#endif
SAFE_FREE((*ads)->server.realm);
SAFE_FREE((*ads)->server.workgroup);
SAFE_FREE((*ads)->server.ldap_server);
- SAFE_FREE((*ads)->server.ldap_uri);
SAFE_FREE((*ads)->auth.realm);
SAFE_FREE((*ads)->auth.password);
SAFE_FREE((*ads)->config.realm);
SAFE_FREE((*ads)->config.bind_path);
- SAFE_FREE((*ads)->config.schema_path);
SAFE_FREE((*ads)->config.ldap_server_name);
-
- SAFE_FREE((*ads)->schema.sfu_uidnumber_attr);
- SAFE_FREE((*ads)->schema.sfu_gidnumber_attr);
- SAFE_FREE((*ads)->schema.sfu_shell_attr);
- SAFE_FREE((*ads)->schema.sfu_homedir_attr);
+ SAFE_FREE((*ads)->config.server_site_name);
+ SAFE_FREE((*ads)->config.client_site_name);
ZERO_STRUCTP(*ads);