/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* 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
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <stdlib.h>
#include <libintl.h>
#include <stdio.h>
#include <errno.h>
#include <strings.h>
#include "ns_sldap.h"
#include "ns_internal.h"
/*
* getldaplaliasbyname() retrieves the aliases information from the LDAP server.
* This is requires that the LDAP naming information (ie. LDAP_CLIENT_CACHE
* file) is configured properly on the client machine.
*
* Return value:
* 0 = success;
* 1 = alias not found;
* -1 = other failure. Contents in answer are undefined.
*/
/*
* This function builds a new string, as identified by realfilter, by
* replacing the first occurrence of '%s' in userdata with the string
* filter provided in the Service Search Descriptor (SSD).
*
* It is used as a call back function by __ns_ldap_list() API.
*
* As an example, lets assume the caller of __ns_ldap_list() is
* accessing password information. The userdata filter would previously
* have been constructed to contain "(&(%s)(userid=fred))". And the SSD
* filter consists of "dept=sds". The new filter would result in
* "(&(dept=sds)(userid=fred))".
*/
int
char **realfilter,
const void *userdata)
{
int filterlen;
int merged = 0;
char *realfilterp;
/* sanity check */
if (realfilter == NULL)
return (NS_LDAP_INVALID_PARAM);
*realfilter = NULL;
return (NS_LDAP_INVALID_PARAM);
if (*realfilter == NULL)
return (NS_LDAP_MEMORY);
while (*userdatap != '\0') {
realfilterp += filterlen;
} else {
}
}
*realfilterp = '\0';
return (NS_LDAP_SUCCESS);
}
char *
{
*retval = -1;
return (NULL);
}
*retval = -1;
return (NULL);
}
answer[0] = '\0';
/* get the aliases */
*retval = -1;
return (NULL);
}
/* get the userdata for __ns_ldap_list filter call back */
*retval = -1;
return (NULL);
}
attribute[0] = MAIL_MEMBER;
/* should we do hardlookup */
if (rc == NS_LDAP_NOTFOUND) {
*retval = 1;
return (NULL);
} else if (rc != NS_LDAP_SUCCESS) {
#ifdef DEBUG
char *p;
(void) __ns_ldap_err2str(rc, &p);
if (errorp) {
} else
#endif /* DEBUG */
(void) __ns_ldap_freeError(&errorp);
*retval = -1;
return (NULL);
}
/* build the return value */
answer[0] = '\0';
len = 0;
comma = 0;
for (i = 0; i < result->entries_count; i++) {
if (attr_value == NULL) {
*retval = -1;
return (NULL);
}
for (j = 0; attr_value[j]; j++) {
tmp = attr_value[j];
tmp++;
*tmp-- = '\0';
}
if (new_answer == NULL) {
(void) __ns_ldap_freeResult(&result);
*retval = -1;
return (NULL);
}
answer = new_answer;
}
if (comma)
else
comma = 1;
}
}
(void) __ns_ldap_freeResult(&result);
errno = 0;
*retval = 0;
return (answer);
}