QsyGetEIMConnectInfo()--Get EIM Connect Information


  Syntax
 #include <qsyeimapi.h>

 #include <eim.h>

 int QsyGetEIMConnectInfo(int          lengthOfConnectInfo,
     EimList    * connectInfo,
                          EimRc      * eimrc)
 
  Service Program Name: QSYS/QSYEIMAPI

  Default Public Authority: *USE

  Threadsafe: Yes

The QsyGetEIMConnectInfo() function returns the connection information that will be used by the operating system when it needs to connect to the EIM domain that is configured for this system or for the master system.


Authorities and Locks

None.

Parameters

lengthOfConnectInfo
(Input)

The number of bytes provided by the caller for the connection information parameter. The minimum size required is 20 bytes. The API will return the number of bytes available for all of the connection information and as much data as space has been provided.

connectInfo
(Output)

A pointer to the data to be returned.

The EimList structure contains information about the returned data. The data returned is a linked list of QsyEimConnectInfo structures. firstEntry is used to get to the first QsyEimConnectInfo structure in the linked list.

EimList structure:

        typedef struct EimList
        {
            unsigned int bytesReturned;     /* Number of bytes actually returned
                                             by the API                       */
            unsigned int bytesAvailable;    /* Number of bytes of available data
                                             that could have been returned by
                                             the API                          */
            unsigned int entriesReturned;   /* Number of entries actually
                                             returned by the API              */
            unsigned int entriesAvailable;  /* Number of entries available to be
                                             returned by the API              */
            unsigned int firstEntry;        /* Displacement to the first linked
                                             list entry. This byte offset is
                                             relative to the start of the
                                             EimList structure.               */
        } EimList;

QsyEimConnectInfo structure:

        #pragma enumsize(4)

        typedef struct QsyEimConnectInfo 
        {
             unsigned int              nextEntry;
                                            /* Displacement to next entry.
                                             This byte offset is relative
                                             to the start of this structure.  */
             enum QsyEimConnectSystem  connectSystem;
                                            /* System connection info is for -
                                             configured (0) or master (1).    */
             enum QsyEimConnectType    connectType;
                                            /* Connection type - simple (0),
                                             kerberos with keytab file (1), or
                                             kerberos with password (2)       */  
             union {
                 struct {
                     enum EimPasswordProtect  protect;
                                            /* Protect value - no protect (0),
                                             cram_md5 (1), or optional
                                             cram_md5 (2)                     */
                     EimListData              bindDN;
                 } simpleConnect;           /* Protect value and bind DN, if
                                             connectType=QSY_EIM_SIMPLE (0)   */
                 struct {
                     EimListData       kerberosPrincipal;
                     EimListData       kerberosRealm;
                 } kerberosPwd;             /* Kerberos information, if
                                             connectType=QSY_KERBEROS_PWD (1) */
                 struct {
                     EimListData       kerberosKeyTab;
                     EimListData       kerberosPrincipal;
                     EimListData       kerberosRealm;
                 } kerberosKeyTab;          /* Kerberos information, if
                                             connectType=
                                               QSY_KERBEROS_KEYTAB (2)        */
                      
             } connectInfo;
        } QsyEimConnectInfo;

EimListData structure:

        typedef struct EimListData
        {
            unsigned int length;            /* Length of data                 */
            unsigned int disp;              /* Displacement to data.  This byte
                                             offset is relative to the start of
                                             the parent structure; that is, the
                                             structure containing this
                                             structure                        */
        } EimListData;
eimrc
(Input/Output)

The structure in which to return error code information. If the return value is not 0, eimrc is set with additional information. This parameter may be NULL. For the format of the structure, see EimRC--EIM Return Code Parameter.


Return Value

The return value from the API. Following each return value is the list of possible values for the messageCatalogMessageID field in the eimrc parameter for that value.

0
Request was successful.

EBADDATA (3028)
eimrc is not valid.

EBUSY (3029)
Unable to allocate internal system object.

EIMERR_NOLOCK (26) Unable to allocate internal system object.

ECONVERT (3490)
Data conversion error.

EIMERR_DATA_CONVERSION (13) Error occurred when converting data between code pages.

EINVAL (3021)
Input parameter was not valid.

EIMERR_EIMLIST_SIZE (16) Length of EimList is not valid. EimList must be at least 20 bytes in length.
EIMERR_PARM_REQ (34) Missing required parameter. Please check API documentation.
EIMERR_PTR_INVAL (35) Pointer parameter is not valid.
EIMERR_SPACE (41) Unexpected error accessing parameter.

ENOMEM (3460)
Unable to allocate required space.

EIMERR_NOMEM (27) No memory available. Unable to allocate required space.

EUNKNOWN (3474)
Unexpected exception.

EIMERR_UNKNOWN (44) Unknown error or unknown system state.

Related Information


Example

The following example gets connection information used by the operating system.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include <eim.h>
#include <qsyeimapi.h>
            
void printListResults(EimList * list)
{
    int i;
    QsyEimConnectInfo * entry;
    char * data;
    int    dataLength;

    printf("\n___________");
    printf("\nBytes Returned    = %d", list->bytesReturned);
    printf("\nBytes Available   = %d", list->bytesAvailable);
    printf("\nEntries Returned  = %d", list->entriesReturned);
    printf("\nEntries Available = %d", list->entriesAvailable);

    entry = (QsyEimConnectInfo *)((char *)list + list->firstEntry);
    for (i = 0; i < list->entriesReturned; i++)
    {
        printf("\n");
        printf("\n***** Entry %d *****  ",i+1);
        printf("\nConnect system : %d ",entry->connectSystem );
        printf("\nConnect type : %d ",entry->connectType );
        
        switch (entry->connectType)  /* Determine connect type. */
          {
            case QSY_EIM_SIMPLE:
               {
                 printf("\nProtect type : %d ",
                   entry->connectInfo.simpleConnect.protect );
                 data = ((char *)entry + 
                   entry->connectInfo.simpleConnect.bindDN.disp );
                 dataLength =
                   entry->connectInfo.simpleConnect.bindDN.length;
                 printf("\n%s : ","Bind DN");
                 if (dataLength > 0)
                     printf("%.*s",dataLength, data);
                 else
                     printf("Not found.");
                 break;
               }
            case QSY_EIM_KERBEROS_KEYTAB:
               {
                 /* Print out the keytab file name */
                 data = ((char *)entry + entry->
                      connectInfo.kerberosKeyTab.kerberosKeyTab.disp );
                 dataLength =
                   entry->connectInfo.kerberosKeyTab.kerberosKeyTab.length;
                 printf("\n%s : ","Keytab file name");
                 if (dataLength > 0)
                     printf("%.*s",dataLength, data);
                 else
                     printf("Not found.");
                 /* Print out the principal */
                 data = ((char *)entry + entry-> 
                       connectInfo.kerberosKeyTab.kerberosPrincipal.disp );
                 dataLength =
                   entry->connectInfo.kerberosKeyTab.kerberosPrincipal.length;
                 printf("\n%s : ","Kerberos principal");
                 if (dataLength > 0)
                     printf("%.*s",dataLength, data);
                 else
                     printf("Not found.");
                 /* Print out the realm */
                 data = ((char *)entry + entry->
                      connectInfo.kerberosKeyTab.kerberosRealm.disp );
                 dataLength =
                   entry->connectInfo.kerberosKeyTab.kerberosRealm.length;
                 printf("\n%s : ","Kerberos realm");
                 if (dataLength > 0)
                     printf("%.*s",dataLength, data);
                 else
                     printf("Not found.");
                 break;
               }
            case QSY_EIM_KERBEROS_PWD:
               {
                 /* Print out the principal */
                 data = ((char *)entry + entry->
                       connectInfo.kerberosPwd.kerberosPrincipal.disp );
                 dataLength =
                   entry->connectInfo.kerberosPwd.kerberosPrincipal.length;
                 printf("\n%s : ","Kerberos principal");
                 if (dataLength > 0)
                     printf("%.*s",dataLength, data);
                 else
                     printf("Not found.");
                 /* Print out the realm */
                 data = ((char *)entry + entry->
                       connectInfo.kerberosPwd.kerberosRealm.disp );
                 dataLength =
                   entry->connectInfo.kerberosPwd.kerberosRealm.length;
                 printf("\n%s : ","Kerberos realm");
                 if (dataLength > 0)
                     printf("%.*s",dataLength, data);
                 else
                     printf("Not found.");
                 break;
               }
          } /* end determine connect type. */

        /* advance to next entry */
        entry = (QsyEimConnectInfo *)((char *)entry + entry->nextEntry);

    }
    printf("\n");

}

int main(int argc, char *argv[])
{
    int rc;
    char       eimerr[100];
    EimRC     *err;
   
    char    listData[5000];
    EimList * list = (EimList * ) listData;

    err = (EimRC *)eimerr;
    err->memoryProvidedByCaller = 100;

    if (0 != (rc = QsyGetEIMConnectInfo(5000,
                                        list,
                                        err)))
    {
        printf("Get connection information error = %d", rc);
        return -1;
    }

    printListResults(list);
              
    return 0;
}


API introduced: V5R2

[ Back to top | Security APIs | APIs by category ]