1 /* alias.c - mail alias lookup routines */
4 * Copyright 2008 by Howard Chu, Symas Corp.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
16 * This code references portions of the nss-ldapd package
17 * written by Arthur de Jong. The nss-ldapd code was forked
18 * from the nss-ldap library written by Luke Howard.
23 /* Vendor-specific attributes and object classes.
25 * ( 1.3.6.1.4.1.42.2.27.1.2.5 NAME 'nisMailAlias' SUP top STRUCTURAL
26 * DESC 'NIS mail alias'
28 * MAY rfc822MailMember )
31 /* the basic search filter for searches */
32 static struct berval alias_filter = BER_BVC("(objectClass=nisMailAlias)");
34 /* the attributes to request with searches */
35 static struct berval alias_keys[] = {
37 BER_BVC("rfc822MailMember"),
47 static int write_alias(nssov_alias_cbp *cbp,Entry *entry)
49 int32_t tmpint32,tmp2int32,tmp3int32;
50 struct berval tmparr[2], empty;
51 struct berval *names, *members;
55 /* get the name of the alias */
56 if (BER_BVISNULL(&cbp->name))
58 a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[0].an_desc);
61 Debug(LDAP_DEBUG_ANY,"alias entry %s does not contain %s value",
62 entry->e_name.bv_val,cbp->mi->mi_attrs[0].an_desc->ad_cname.bv_val,0 );
71 BER_BVZERO(&names[1]);
73 /* get the members of the alias */
74 a = attr_find(entry->e_attrs, cbp->mi->mi_attrs[1].an_desc);
81 /* for each name, write an entry */
82 for (i=0;!BER_BVISNULL(&names[i]);i++)
84 WRITE_INT32(cbp->fp,NSLCD_RESULT_SUCCESS);
85 WRITE_BERVAL(cbp->fp,&names[i]);
86 WRITE_BVARRAY(cbp->fp,members);
96 struct berval filter = {sizeof(fbuf)};
98 READ_STRING_BUF2(fp,cbp.buf,sizeof(cbp.buf));
99 cbp.name.bv_len = tmpint32;
100 cbp.name.bv_val = cbp.buf;,
101 Debug(LDAP_DEBUG_TRACE,"nssov_alias_byname(%s)",cbp.name.bv_val,0,0);,
102 NSLCD_ACTION_ALIAS_BYNAME,
103 nssov_filter_byname(cbp.mi,0,&cbp.name,&filter)
108 struct berval filter;
109 /* no parameters to read */
110 BER_BVZERO(&cbp.name);,
111 Debug(LDAP_DEBUG,"nssov_alias_all()",0,0,0);,
112 NSLCD_ACTION_ALIAS_ALL,
113 (filter=cbp.mi->mi_filter,0)