/* XDSHLI_BUILD.C V5.5-4 *%COPYRIGHT_START% * * Copyright Digital Equipment Corporation 1993, 1995. All rights reserved * * Restricted Rights: Use, duplication, or disclosure by the U.S Government is * subject to restrictions as set forth in subparagraph (C) (1) (ii) of DFARS * 252.227-7013, or in FAR 52.227-19, or in FAR 52.227-14 Alt, III, as * applicable. Unpublished rights reserved under applicable copyright laws. * * This software is proprietary to and embodies the confidential technology of * Digital Equipment Corporation. Possession, use, or copying of this software * and media is authorized only pursuant to a valid written license from * Digital or an authorized sublicensor. * *%COPYRIGHT_END% */ /* **++ ** FACILITY: XDSHLI - extension to X.500 XDS/OM interface ** ** The XDS High Level Interface (XDSHLI) helps build XDS/OM applications ** by providing a set of useful services. XDSHLI complements the XDS/OM API ** by hiding some of its complexities, but allowing access to these ** features if they are required. ** ** See XDSHLI.H for more information. ** ** MODULE DESCRIPTION: ** ** This module contains those XDSHLI routines which are associated ** with creating OM objects. ** They are ** dsX_make_session() - creates Session OM object with credentials ** dsX_make_selection() - creates Entry-Information-Selection object ** ** XDSHLI.H contains the functionality description of these routines, ** and other related information. ** ** AUTHORS: ** ** IRD ** ** CREATION DATE: 7-Aug-1993 ** ** ** MODIFICATION HISTORY: ** ** 000 7-Aug-1993 IRD Creation ** 001 24-Aug-1993 IRD Minor interface changes and initial coding ** 002 26-Aug-1993 IRD Implement dsX_make_selection(). ** 003 3-Sep-1993 IRD Implement dsX_make_session(). ** 004 13-Oct-1993 CMB Minor changes to comments ** 005 12-Nov-1993 IRD Change include statements **-- */ /* ** ** INCLUDE FILES ** */ #include #include "xdshli.h" #include "xdshli_private.h" /* dsX_make_session() **++ ** This function returns an Session OM Private Object ** containing the given credentials. ** ** See XDSHLI.H for a fuller description. **-- */ extern OM_private_object dsX_make_session( OM_workspace workspace, /* IN - OM workspace */ OM_private_object name, /* IN - name object */ char *password ) /* IN - Null terminated password */ { OM_private_object session = NULL ; unsigned int i ; OM_descriptor desc[3] ; /* * Create an initialized Session OM private object. This will contain * the default values for the DSA to connect to (DS_DSA_ADDRESS), and * possibly the name of the requestor (DS_REQUESTOR). * These default values are read from the applications defaults * if they have been configured. See the Digital X.500 Directory Service * Management guide for more information. */ if ( OM_STATUS_OK(om_create(DS_C_SESSION, OM_TRUE, workspace, &session)) ) { i = 0 ; /* * If the caller has provided a 'name', create a descriptor with this * value. */ if ( name != NULL ) { OMX_OBJECT_DESC( desc[i], DS_REQUESTOR, name ) ; i++ ; } /* * If the caller has provided a password, create a descriptor with * this value. Note that that the password OM Attribute is a Digital * extension, and may not apply to other implementations. */ if ( password != NULL ) { OMX_ZSTRING_DESC( desc[i], OM_S_OCTET_STRING, DSX_PASSWORD, password ); i++ ; } /* * Create a NULL descriptor to terminate the OM public object. */ OMX_OM_NULL_DESC( desc[i] ) ; /* * Put the credentials (if any) into the Session OM object. * If there are no credentials, the source OM object (desc) just * consists of a NULL descriptor, and om_put() does not change * contents of the Session OM object. */ OM_STATUS_OK( om_put(session, OM_REPLACE_ALL, desc, NULL, 0, 0) ) ; } return session ; } /* dsX_make_selection() **++ ** This function returns an Entry-Information-Selection OM Private Object ** containing the given a list of Attribute-Types. ** ** See XDSHLI.H for a fuller description. **-- */ extern OM_private_object dsX_make_selection( OM_workspace workspace, /* IN - workspace */ OM_object_identifier ** attributes /* IN - list of attributes required, NULL terminated */ ) { OM_private_object entry_sel = NULL ; OM_descriptor descriptor[2] ; unsigned int i = 0; /* * Create an initialised Entry-Information-Selection OM private object. */ if ( OM_STATUS_OK(om_create(DS_C_ENTRY_INFO_SELECTION, OM_TRUE, workspace, &entry_sel)) ) { /* * The initialised OM object has All-Attributes set to TRUE, * and Information-Type set to 'types-and-values'. These values * are correct where all attributes and their values are to * be returned from a Directory interrogation. * If specific attributes are to be returned from the Directory, the * object has to be modified. */ if ( attributes != NULL && *attributes != NULL ) { /* * 'attribute' contains specific attibutes to be returned. * Set All-Attributes to FALSE, and add the required attributes * as Attributes-Selected. */ /* * Change the value of All-Attributes to FALSE. */ OMX_BOOLEAN_DESC( descriptor[0], DS_ALL_ATTRIBUTES, OM_FALSE ) ; OMX_OM_NULL_DESC( descriptor[1] ) ; OM_STATUS_OK( om_put(entry_sel, OM_REPLACE_ALL, descriptor, NULL, 0, 0) ) ; /* * Add each of the Attribute Type Object-Identifiers in 'attributes'. * First initialize the OM public object to contain the correct * type and syntax fields, and a NULL descriptor. */ OMX_STRING_DESC( descriptor[0], OM_S_OBJECT_IDENTIFIER_STRING, DS_ATTRIBUTES_SELECTED, 0, 0 ); OMX_OM_NULL_DESC( descriptor[1] ) ; /* * Step through the given list until the NULL termination is found. */ while ( attributes[i] != NULL ) { /* * The descriptor was initialised before entering this loop. * Use structure assignment to setup 'elements' and 'length' * fields in the descriptor for this Attribute Type. */ descriptor[0].value.string = *(attributes[i]) ; /* * Insert the value into the Entry-Information-Selection * OM private object. Use OM_INSERT_AT_END so that * no existing values are lost. */ OM_STATUS_OK( om_put(entry_sel, OM_INSERT_AT_END, descriptor, NULL, 0, 0) ) ; /* * Increment 'i' to access the next attribute type */ i++ ; } } } return entry_sel ; }