1 /* alias.c - mail alias lookup routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2008-2013 The OpenLDAP Foundation.
6 * Portions Copyright 2008 by Howard Chu, Symas Corp.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This code references portions of the nss-ldapd package
19 * written by Arthur de Jong. The nss-ldapd code was forked
20 * from the nss-ldap library written by Luke Howard.
25 /* Vendor-specific attributes and object classes.
27 * ( 1.3.6.1.4.1.42.2.27.1.2.5 NAME 'nisMailAlias' SUP top STRUCTURAL
28 * DESC 'NIS mail alias'
30 * MAY rfc822MailMember )
33 /* the basic search filter for searches */
34 static struct berval alias_filter = BER_BVC("(objectClass=nisMailAlias)");
36 /* the attributes to request with searches */
37 static struct berval alias_keys[] = {
39 BER_BVC("rfc822MailMember"),
49 static int write_alias(nssov_alias_cbp *cbp,Entry *entry)
51 int32_t tmpint32,tmp2int32,tmp3int32;
52 struct berval tmparr[2], empty;
53 struct berval *names, *members;
57 /* get the name of the alias */
58 if (BER_BVISNULL(&cbp->name))
60 a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[0].an_desc);
63 Debug(LDAP_DEBUG_ANY,"alias entry %s does not contain %s value\n",
64 entry->e_name.bv_val,cbp->mi->mi_attrs[0].an_desc->ad_cname.bv_val,0 );
73 BER_BVZERO(&names[1]);
75 /* get the members of the alias */
76 a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[1].an_desc);
83 /* for each name, write an entry */
84 for (i=0;!BER_BVISNULL(&names[i]);i++)
86 WRITE_INT32(cbp->fp,NSLCD_RESULT_BEGIN);
87 WRITE_BERVAL(cbp->fp,&names[i]);
88 WRITE_BVARRAY(cbp->fp,members);
98 struct berval filter = {sizeof(fbuf)};
100 READ_STRING(fp,cbp.buf);
101 cbp.name.bv_len = tmpint32;
102 cbp.name.bv_val = cbp.buf;,
103 Debug(LDAP_DEBUG_TRACE,"nssov_alias_byname(%s)\n",cbp.name.bv_val,0,0);,
104 NSLCD_ACTION_ALIAS_BYNAME,
105 nssov_filter_byname(cbp.mi,0,&cbp.name,&filter)
110 struct berval filter;
111 /* no parameters to read */
112 BER_BVZERO(&cbp.name);,
113 Debug(LDAP_DEBUG,"nssov_alias_all()\n",0,0,0);,
114 NSLCD_ACTION_ALIAS_ALL,
115 (filter=cbp.mi->mi_filter,0)