DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T d

⟦f6f2eefca⟧ TextFile

    Length: 10431 (0x28bf)
    Types: TextFile
    Names: »dl_x500.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« 
        └─⟦e5a54fb17⟧ 
            └─⟦this⟧ »pp-5.0/Chans/dirlist/dl_x500.c« 

TextFile

/* dl_x500.c: */

# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Chans/dirlist/RCS/dl_x500.c,v 5.0 90/09/20 15:45:41 pp Exp Locker: pp $";
# endif

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Chans/dirlist/RCS/dl_x500.c,v 5.0 90/09/20 15:45:41 pp Exp Locker: pp $
 *
 * $Log:	dl_x500.c,v $
 * Revision 5.0  90/09/20  15:45:41  pp
 * rcsforce : 5.0 public release
 * 
 */



#include "dlist.h"
#include <isode/quipu/dua.h>
#include <isode/quipu/read.h>
#include <isode/quipu/modify.h>
#include <isode/quipu/ds_search.h>
#include <isode/quipu/connection.h>	/* ds_search uses di_block - include this for lint !!! */
#include <isode/quipu/bind.h>

extern AttributeType at_Member;
extern AttributeType at_RoleOccupant;
extern AttributeType at_CommonName;
extern AttributeType at_Owner;
extern AttributeType at_Permit;
extern AttributeType at_Policy;
extern AttributeType at_ORAddress;
extern AttributeType at_RFC822;
extern AttributeType at_GroupMember;
extern AttributeType at_ObjectClass;
extern OID role_oc;

extern LLog * log_dsap;

extern Filter strfilter(), ocfilter(), joinfilter();
static Attr_Sequence mailas = NULLATTR;

static Attr_Sequence ds_cache_read (dn,as) 
DN dn;
Attr_Sequence as;
{
struct ds_read_arg read_arg;
struct ds_read_result result;
struct DSError  error;
static CommonArgs ca = default_common_args;
Entry ptr;

	if ((ptr = local_find_entry (dn,TRUE)) != NULLENTRY) {
		if (ptr->e_complete)
			return (ptr->e_attributes);  		
		if (as != NULLATTR) {
			Attr_Sequence tmp;
			for (tmp = as; tmp!= NULLATTR; tmp = tmp->attr_link) 
#if ISODE >= 65
				if (as_find_type(ptr->e_attributes,tmp->attr_type) == NULLATTR) 
#else
				if (as_find_type(ptr->e_attributes,&tmp->attr_type) == NULLATTR) 
#endif
					goto do_read;

			return (ptr->e_attributes);  			
		}
	}

do_read:;

	read_arg.rda_common = ca; /* struct copy */

	read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
	read_arg.rda_eis.eis_allattributes = FALSE;
	read_arg.rda_eis.eis_select = as;
	read_arg.rda_object = dn;
	
	if (ds_read (&read_arg, &error, &result) != DS_OK) {
		log_ds_error (&error);
		ds_error_free (&error);
		return NULLATTR;
	}

#if ISODE < 65
	(void) as_decode (result.rdr_entry.ent_attr);
#endif
	result.rdr_entry.ent_attr = as_merge (result.rdr_entry.ent_attr,as_cpy(as));

	cache_entry (&result.rdr_entry,FALSE,TRUE);
	return (result.rdr_entry.ent_attr);
}


Attr_Sequence dn2addr (dn) 
DN dn;
{
Attr_Sequence tmp, found;

	if (mailas == NULLATTR) {
		Attr_Sequence as;
		mailas = as_comp_new (at_ORAddress,  NULLAV, NULLACL_INFO);
		as = as_comp_new (at_RFC822,  NULLAV, NULLACL_INFO);
		mailas = as_merge (mailas,as);
		as = as_comp_new (at_ObjectClass,  NULLAV, NULLACL_INFO);
		mailas = as_merge (mailas,as);
		as = as_comp_new (at_RoleOccupant,  NULLAV, NULLACL_INFO);
		mailas = as_merge (mailas,as);
	}

	tmp = ds_cache_read (dn,mailas);

	/* Have we got an address ? */
	if ((found = as_find_type (tmp,at_ORAddress)) != NULLATTR) 
		return tmp;

	if ((found = as_find_type (tmp,at_RFC822)) == NULLATTR) 
		return tmp;

	/* NO address, is it a role ? */
	if ((found = as_find_type (tmp,at_ObjectClass)) == NULLATTR) 
		return NULLATTR;

	if (check_in_oc(role_oc,found->attr_value)) {
		/* Its a role :- follow member... */
		if ((found = as_find_type (tmp,at_RoleOccupant)) == NULLATTR) 
			return NULLATTR;

		tmp = dn2addr ((DN)&found->attr_value->avseq_av);
	}

	return tmp;
	
}


Attr_Sequence dir_getdl_aux (dn)
DN dn;
{
static Attr_Sequence astop = NULLATTR;
Attr_Sequence res;

	if (astop == NULLATTR) {
		Attr_Sequence as;
		astop = as_comp_new (at_Member,  NULLAV, NULLACL_INFO);
		as = as_comp_new (at_Owner,  NULLAV, NULLACL_INFO);
		astop = as_merge (astop,as);
		as = as_comp_new (at_Permit,  NULLAV, NULLACL_INFO);
		astop = as_merge (astop,as);
		as = as_comp_new (at_Policy,  NULLAV, NULLACL_INFO);
		astop = as_merge (astop,as);
/*
		as = as_comp_new (acl_at,  NULLAV, NULLACL_INFO);
		astop = as_merge (astop,as);
*/
	}
	res = ds_cache_read (dn,astop);
	return res;
}

Attr_Sequence dir_getdl (list)
char * list;
{
DN dn;
Attr_Sequence as;

	if ((dn = str2dn(list)) == NULLDN)
		return NULLATTR;

	as = dir_getdl_aux (dn);
	dn_free (dn);
	return as;
} 

Attr_Sequence read_group_entry (dn)
DN dn;
{
static Attr_Sequence astop = NULLATTR;

	if (astop == NULLATTR) 
		astop = as_comp_new (at_GroupMember,  NULLAV, NULLACL_INFO);

	return (ds_cache_read (dn,astop));
}


or_modify (ps,old,newname,at,dn) 
PS ps;
ORName * old;
OR_ptr newname;
AttributeType at;
DN dn;
{
struct ds_modifyentry_arg mod_arg;
struct DSError  error;
static CommonArgs ca = default_common_args;
struct entrymod *emnew;
AttributeValue av;
AV_Sequence avs;
ORName * newor;
ORName * orName_cpy();
OR_ptr or_cpy();

	mod_arg.mea_common = ca;
	mod_arg.mea_object = dn;

	emnew = em_alloc ();
	emnew->em_type = EM_ADDVALUES;
	av = AttrV_alloc();
	av->av_syntax = str2syntax("ORName");
	newor = orName_cpy (old);
	if (newor->on_or != NULLOR)
		or_free (newor->on_or);
	newor->on_or = or_cpy(newname);
	av->av_struct = (caddr_t) newor;
	avs = avs_comp_new(av);
	emnew->em_what = as_comp_new (AttrT_cpy(at),avs,NULLACL_INFO);

	mod_arg.mea_changes = emnew;

 	emnew = em_alloc ();
	emnew->em_type = EM_REMOVEVALUES;
	av = AttrV_alloc();
	av->av_syntax = str2syntax("ORName");
	av->av_struct = (caddr_t) orName_cpy(old);
	avs = avs_comp_new(av);
	emnew->em_what = as_comp_new (AttrT_cpy(at),avs,NULLACL_INFO);
	emnew->em_next = NULLMOD;

	mod_arg.mea_changes->em_next = emnew;

	if (ds_modifyentry (&mod_arg, &error) != DS_OK) {
		ds_error (ps, &error);
		return FALSE;
	}
	delete_cache (old->on_dn);

	ems_free (mod_arg.mea_changes);

	return TRUE;
}

dl_modify (ps,name,dn,delete) 
PS ps;
ORName * name;
DN dn;
char delete;
{
struct ds_modifyentry_arg mod_arg;
struct DSError  error;
static CommonArgs ca = default_common_args;
struct entrymod *emnew;
AttributeValue av;
AV_Sequence avs;

	mod_arg.mea_common = ca;
	mod_arg.mea_object = dn;

	emnew = em_alloc ();
	if (delete)
		emnew->em_type = EM_REMOVEVALUES;
	else
		emnew->em_type = EM_ADDVALUES;
	av = AttrV_alloc();
	av->av_syntax = str2syntax("ORName");
	av->av_struct = (caddr_t) name;
	avs = avs_comp_new(av);
	emnew->em_what = as_comp_new (AttrT_cpy(at_Member),avs,NULLACL_INFO);
	emnew->em_next = NULLMOD;

	mod_arg.mea_changes = emnew;

	if (ds_modifyentry (&mod_arg, &error) != DS_OK) {
		ds_error (ps, &error);
		return FALSE;
	}
	delete_cache (dn);
	ems_free (mod_arg.mea_changes);

	return TRUE;
}

dl_bind (name,passwd)
DN name;
char * passwd;
{
  struct ds_bind_arg bindarg;
  struct ds_bind_arg bindresult;
  struct ds_bind_error binderr;

  bindarg.dba_version = DBA_VERSION_V1988;

  if ((bindarg.dba_dn = name) == NULLDN) {
	bindarg.dba_passwd_len = 0;
	bindarg.dba_passwd [0] = '\0';
  } else {
	bindarg.dba_passwd_len = strlen (passwd);
	(void) strcpy (bindarg.dba_passwd,passwd);
  }

  if (ds_bind (&bindarg,&binderr,&bindresult) != DS_OK)
    	return NOTOK;
  else
	return OK;
}


dl_unbind ()
{
	(void) ds_unbind ();
}


DN str2dl (str,localdn)
char * str;
DN localdn;
{
extern int print_parse_errors;
DN res;
int old;
struct ds_search_arg search_arg;
static struct ds_search_result result;
struct DSError err;
static CommonArgs ca = default_common_args;
Filter filtcn, filtoc, filtand;

	old = print_parse_errors;
	print_parse_errors = FALSE;
	res = str2dn (str);
	print_parse_errors = old;

	if (res != NULLDN)
		return res;

	filtcn = strfilter (at_CommonName,str,FILTERITEM_EQUALITY);
	if ((filtoc = ocfilter ("ppDistributionList")) == NULLFILTER)
		return NULLDN;

	filtoc->flt_next = filtcn;
	filtand = joinfilter (filtoc,FILTER_AND);

	search_arg.sra_baseobject = localdn;
	search_arg.sra_filter = filtand;
	search_arg.sra_subset = SRA_ONELEVEL;
	search_arg.sra_searchaliases = FALSE;
	search_arg.sra_common = ca; /* struct copy */
	search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
	search_arg.sra_eis.eis_allattributes = FALSE;
	search_arg.sra_eis.eis_select = NULLATTR;

	if (ds_search (&search_arg, &err, &result) != DS_OK) {
		filter_free (filtoc);
		log_ds_error (&err);
		ds_error_free (&err);
		return NULLDN;
	}
	filter_free (filtoc);

	if (result.CSR_entries) {
#if ISODE < 65
		(void) dn_decode (result.CSR_entries->ent_dn);
#endif
		return (result.CSR_entries->ent_dn);
	} 

	return NULLDN;
	
}


DN search_postmaster (localdn)
DN localdn;
{
struct ds_search_arg search_arg;
static struct ds_search_result result;
struct DSError err;
static CommonArgs ca = default_common_args;
Filter filtcn;

	if (mailas == NULLATTR) {
		Attr_Sequence as;
		mailas = as_comp_new (at_ORAddress,  NULLAV, NULLACL_INFO);
		as = as_comp_new (at_RFC822,  NULLAV, NULLACL_INFO);
		mailas = as_merge (mailas,as);
		as = as_comp_new (at_ObjectClass,  NULLAV, NULLACL_INFO);
		mailas = as_merge (mailas,as);
		as = as_comp_new (at_RoleOccupant,  NULLAV, NULLACL_INFO);
		mailas = as_merge (mailas,as);
	}

	filtcn = strfilter (at_CommonName,"PostMaster",FILTERITEM_EQUALITY);

	search_arg.sra_baseobject = localdn;
	search_arg.sra_filter = filtcn;
	search_arg.sra_subset = SRA_ONELEVEL;
	search_arg.sra_searchaliases = TRUE;
	search_arg.sra_common = ca; /* struct copy */
	search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
	search_arg.sra_eis.eis_allattributes = FALSE;
	search_arg.sra_eis.eis_select = mailas;

	if (ds_search (&search_arg, &err, &result) != DS_OK) {
		filter_free (filtcn);
		log_ds_error (&err);
		ds_error_free (&err);
		return NULLDN;
	}
	filter_free (filtcn);

	if (result.CSR_entries) {
		cache_entry (result.CSR_entries,FALSE,TRUE);
		return (result.CSR_entries->ent_dn);
	} 

	return NULLDN;
}
	
dl_showentry(ps,dn)
PS ps;
DN dn;
{
struct ds_read_arg read_arg;
struct ds_read_result result;
struct DSError  error;
static CommonArgs ca = default_common_args;
Entry ptr;

	if ((ptr = local_find_entry (dn,TRUE)) != NULLENTRY) 
		if (ptr->e_complete) {
			as_print (ps,ptr->e_attributes,READOUT);
			return;
		}

	read_arg.rda_common = ca; /* struct copy */

	read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
	read_arg.rda_eis.eis_allattributes = TRUE;
	read_arg.rda_eis.eis_select = NULLATTR;
	read_arg.rda_object = dn;
	
	if (ds_read (&read_arg, &error, &result) != DS_OK) 
		ds_error(ps,&error);

#if ISODE < 65
	(void) as_decode (result.rdr_entry.ent_attr);
#endif

	cache_entry (&result.rdr_entry,FALSE,TRUE);

	as_print (ps,result.rdr_entry.ent_attr,READOUT);
}