summaryrefslogtreecommitdiff
path: root/usr/src/lib/libsldap/common/ns_mapping.c
diff options
context:
space:
mode:
authorJulian Pullen <Julian.Pullen@Sun.COM>2010-07-02 10:46:04 +0100
committerJulian Pullen <Julian.Pullen@Sun.COM>2010-07-02 10:46:04 +0100
commit9f2fd570dfad3c35512617ae887140b15e3ec4c5 (patch)
tree3c31e673d7b92cdd0719422693002700aa126679 /usr/src/lib/libsldap/common/ns_mapping.c
parentb1385420941f689de1d9c1c64d8c6b19b63b5b3e (diff)
downloadillumos-gate-9f2fd570dfad3c35512617ae887140b15e3ec4c5.tar.gz
6636343 The SSS control generated by "libsldap.so.1" cannot work with Active Directory in VLV searches
6929861 NS switch LDAP enumeration terminates prematurely if LDAP mandatory attributes are missing 6963912 libsldap does not work with the VLV response from Active Directory
Diffstat (limited to 'usr/src/lib/libsldap/common/ns_mapping.c')
-rw-r--r--usr/src/lib/libsldap/common/ns_mapping.c57
1 files changed, 37 insertions, 20 deletions
diff --git a/usr/src/lib/libsldap/common/ns_mapping.c b/usr/src/lib/libsldap/common/ns_mapping.c
index 686a57ddb9..1ceb035941 100644
--- a/usr/src/lib/libsldap/common/ns_mapping.c
+++ b/usr/src/lib/libsldap/common/ns_mapping.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,9 @@
* CDDL HEADER END
*/
/*
- * Copyright 2000-2003 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdlib.h>
#include <strings.h>
#include <ctype.h>
@@ -350,7 +346,7 @@ __s_api_parseASearchDesc(const char *service,
return (NS_LDAP_INVALID_PARAM);
ptr = (ns_ldap_search_desc_t *)
- calloc(1, sizeof (ns_ldap_search_desc_t));
+ calloc(1, sizeof (ns_ldap_search_desc_t));
if (ptr == NULL)
return (NS_LDAP_MEMORY);
@@ -358,7 +354,7 @@ __s_api_parseASearchDesc(const char *service,
/* Get the default scope */
if ((rc = __ns_ldap_getParam(NS_LDAP_SEARCH_SCOPE_P,
- &paramVal, errorp)) != NS_LDAP_SUCCESS) {
+ &paramVal, errorp)) != NS_LDAP_SUCCESS) {
(void) __ns_ldap_freeError(errorp);
__ns_ldap_freeASearchDesc(ptr);
ptr = NULL;
@@ -629,14 +625,14 @@ __ns_ldap_saveSearchDesc(ns_ldap_search_desc_t ***sdlist,
*cnt = 0;
*max = NS_SDESC_MAX;
*sdlist = (ns_ldap_search_desc_t **)
- calloc(*max, sizeof (ns_ldap_search_desc_t *));
+ calloc(*max, sizeof (ns_ldap_search_desc_t *));
if (*sdlist == NULL)
return (-1);
} else if (*cnt+1 >= *max) {
*max += NS_SDESC_MAX;
tmplist = (ns_ldap_search_desc_t **)
- realloc((void *)(*sdlist),
- *max * sizeof (ns_ldap_search_desc_t *));
+ realloc((void *)(*sdlist),
+ *max * sizeof (ns_ldap_search_desc_t *));
if (tmplist == NULL)
return (-1);
else
@@ -677,7 +673,7 @@ int __ns_ldap_getSearchDescriptors(
*errorp = NULL;
rc = __ns_ldap_getParam(NS_LDAP_SERVICE_SEARCH_DESC_P,
- (void ***)&param, errorp);
+ (void ***)&param, errorp);
if (rc != NS_LDAP_SUCCESS) {
return (rc);
}
@@ -692,7 +688,7 @@ int __ns_ldap_getSearchDescriptors(
(void) snprintf(errstr, sizeof (errstr),
gettext("No configuration information available."));
MKERROR(LOG_ERR, *errorp, NS_CONFIG_NOTLOADED, strdup(errstr),
- NULL);
+ NULL);
return (NS_LDAP_CONFIG);
}
@@ -709,7 +705,7 @@ int __ns_ldap_getSearchDescriptors(
/* Convert a SEARCH_DN to a search descriptor */
for (; *sdl; sdl++) {
ret = (ns_ldap_search_desc_t *)
- calloc(1, sizeof (ns_ldap_search_desc_t));
+ calloc(1, sizeof (ns_ldap_search_desc_t));
if (ret == NULL) {
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
__s_api_free2dArray(sdl_save);
@@ -726,7 +722,7 @@ int __ns_ldap_getSearchDescriptors(
/* default scope */
if ((rc = __ns_ldap_getParam(NS_LDAP_SEARCH_SCOPE_P,
- &paramVal, errorp)) != NS_LDAP_SUCCESS) {
+ &paramVal, errorp)) != NS_LDAP_SUCCESS) {
(void) __ns_ldap_freeASearchDesc(ret);
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
__s_api_free2dArray(sdl_save);
@@ -775,17 +771,17 @@ int __ns_ldap_getSearchDescriptors(
if (rc != NS_LDAP_SUCCESS) {
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
(void) snprintf(errstr, (2 * MAXERROR), gettext(
- "Invalid serviceSearchDescriptor (%s). "
- "Illegal configuration"), *sdl);
+ "Invalid serviceSearchDescriptor (%s). "
+ "Illegal configuration"), *sdl);
(void) __ns_ldap_freeParam(&param);
param = NULL;
MKERROR(LOG_ERR, *errorp, NS_CONFIG_SYNTAX,
- strdup(errstr), NULL);
+ strdup(errstr), NULL);
return (rc);
}
if (ret != NULL) {
rc = __ns_ldap_saveSearchDesc(
- &sdlist, &cnt, &max, ret);
+ &sdlist, &cnt, &max, ret);
}
if (rc < 0) {
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
@@ -1028,3 +1024,24 @@ char **__ns_ldap_mapAttributeList(
}
return (cpp);
}
+
+char *
+__ns_ldap_mapAttribute(
+ const char *service,
+ const char *origAttr)
+{
+ char **npp;
+ char *mappedAttr;
+
+ if (origAttr == NULL)
+ return (NULL);
+
+ npp = __ns_ldap_getMappedAttributes(service, origAttr);
+ if (npp && npp[0]) {
+ mappedAttr = strdup(npp[0]);
+ __s_api_free2dArray(npp);
+ } else {
+ mappedAttr = strdup(origAttr);
+ }
+ return (mappedAttr);
+}