eimListDomains()--List EIM Domain Objects


  Syntax
 #include <eim.h>

 int eimListDomains(char           * ldapURL,
                    EimConnectInfo   connectInfo,
                    unsigned int     lengthOfListData,
                    EimList        * listData,
        EimRC          * eimrc)
 
  Service Program Name: QSYS/QSYEIM

  Default Public Authority: *USE

  Threadsafe: Yes

The eimListDomains() function can be used to list information for a single EIM domain or list information for all EIM domains that are reachable from this platform in the network.


Authorities and Locks

EIM Data
Access to EIM data is controlled by EIM access groups. LDAP administrators also have access to EIM data. The access groups whose members have authority to the EIM data for this API follow:

The list returned contains only the information that the user has authority to access.


Parameters

ldapURL  (Input)
A uniform resource locator (URL) that contains the EIM host information. This URL has the following format:
    ldap://host:port/dn
          or
    ldaps://host:port/dn

where:

Examples:


connectInfo  (Input)
Connect information. EIM uses ldap. This parameter provides the information required to bind to ldap.

If the system is configured to connect to a secure port, EimSSLInfo is required.

For EIM_SIMPLE connect type, the creds field should contain the EimSimpleConnectInfo structure with a binddn and password. EimPasswordProtect is used to determine the level of password protection on the ldap bind.

EIM_PROTECT_NO (0) The clear-text password is sent on the bind.
EIM_PROTECT_CRAM_MD5 (1) The protected password is sent on the bind. The server side must support cram-md5 protocol to send the protected password.
EIM_PROTECT_CRAM_MD5_OPTIONAL (2) The protected password is sent on the bind if the cram-md5 protocol is supported. Otherwise, the clear-text password is sent.

For EIM_KERBEROS, the default logon credentials are used. The kerberos creds field must be NULL.

For EIM_CLIENT_AUTHENTICATION, the creds field is ignored. EimSSLInfo must be provided.

The structure layouts follow:

   enum EimPasswordProtect {
       EIM_PROTECT_NO,              
       EIM_PROTECT_CRAM_MD5,
       EIM_PROTECT_CRAM_MD5_OPTIONAL
   };
   enum EimConnectType {
       EIM_SIMPLE,
       EIM_KERBEROS,
       EIM_CLIENT_AUTHENTICATION
   };

   typedef struct EimSimpleConnectInfo 
   {
        enum EimPasswordProtect protect;
        char * bindDn;
        char * bindPw;
   } EimSimpleConnectInfo;

   typedef struct EimSSLInfo 
   {
        char * keyring;
        char * keyring_pw;
        char * certificateLabel;
   } EimSSLInfo; 

   typedef struct EimConnectInfo
   {
        enum EimConnectType type;
        union {
            gss_cred_id_t * kerberos;
            EimSimpleConnectInfo simpleCreds;
        } creds;
      EimSSLInfo * ssl;
   } EimConnectInfo;      
lengthOfListData  (Input)
The number of bytes provided by the caller for the list of domains. Minimum size required is 20 bytes. The API will return the number of bytes available for the entire list and as much data as space has been provided.

listData  (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 EimDomain structures. firstEntry is used to get to the first EimDomain 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;

EimDomain structure:

   typedef struct EimDomain
   {
       unsigned int nextEntry;         /* Displacement to next entry.  This
                                        byte offset is relative to the
                                        start of this structure          */
       EimListData name;               /* Domain name                    */
       EimListData dn;                 /* Distinguished name for the domain 
                                                                         */
       EimListData description;        /* Description                    */
       enum EimStatus  policyAssociations;  /* Policy associations
						   attribute             */
   } EimDomain;

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 will be 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.

EACCES
Access denied. Not enough permissions to access data.

EIMERR_ACCESS (1) Insufficient access to EIM data.

EBADDATA
eimrc is not valid.

EBADNAME
EIM domain not found or insufficient access to EIM data.

EIMERR_NODOMAIN (24) EIM Domain not found or insufficient access to EIM data.

ECONVERT
Data conversion error.

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

EINVAL
Input parameter was not valid.

EIMERR_CONN_INVAL (54) Connection type is not valid.
EIMERR_EIMLIST_SIZE (16) Length of EimList is not valid. EimList must be at least 20 bytes in length.
EIMERR_NOT_SECURE (32) The system is not configured to connect to a secure port. Connection type of EIM_CLIENT_AUTHENTICATION is not valid.
EIMERR_PARM_REQ (34) Missing required parameter. Please check API documentation.
EIMERR_PROTECT_INVAL (22) The protect parameter in EimSimpleConnectInfo is not valid.
EIMERR_PTR_INVAL (35) Pointer parameter is not valid.
EIMERR_SPACE (41) Unexpected error accessing parameter.
EIMERR_SSL_REQ (42) The system is configured to connect to a secure port. EimSSLInfo is required.
EIMERR_URL_NODOMAIN (46) URL has no domain (required).
EIMERR_URL_NOHOST (47) URL does not have a host.
EIMERR_URL_NOTLDAP (49) URL does not begin with ldap.
EIMERR_INVALID_DN (66) Distinguished Name (DN) is not valid.

ENOMEM
Unable to allocate required space.

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

ENOTSUP
Connection type is not supported.

Connection type is not supported.
EIMERR_CONN_NOTSUPP (12)

EUNKNOWN
Unexpected exception.

EIMERR_LDAP_ERR (23) Unexpected LDAP error. %s
EIMERR_UNKNOWN (44) Unknown error or unknown system state.

Related Information


Example

The following example lists the information for the specified EIM domain.

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

#include <eim.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

void printListResults(EimList * list);
void printListData(char * fieldName,
                   void * entry,
                   int offset);

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

   
    char * ldapURL = "ldap://eimsystem:389/ibm-eimDomainName=myEimDomain,o=mycompany,c=us";
    
    EimConnectInfo con;
    
    /* Set up connection information            */
    con.type = EIM_SIMPLE;
    con.creds.simpleCreds.protect = EIM_PROTECT_NO;
    con.creds.simpleCreds.bindDn = "cn=admin";
    con.creds.simpleCreds.bindPw = "secret";
    con.ssl = NULL;

    /* Set up error structure.                  */
    memset(eimerr,0x00,100);
    err = (EimRC *)eimerr;
    err->memoryProvidedByCaller = 100;

    
    /* Get info for specified domain            */
    if (0 != (rc = eimListDomains(ldapURL,
                                  con,
                                  1000,
                                  list,
          err)))
    {
  printf("List domain error = %d", rc);
  return -1;
    }

    /* Print the results                        */
    printListResults(list);
    return 0;
}
            
void printListResults(EimList * list)
{
    int i;
    EimDomain * entry;
    EimListData * listData;
    char * data;
    int dataLength;

    printf("___________\n");
    printf("   bytesReturned    = %d\n", list->bytesReturned);
    printf("   bytesAvailable   = %d\n", list->bytesAvailable);
    printf("   entriesReturned  = %d\n", list->entriesReturned);
    printf("   entriesAvailable = %d\n", list->entriesAvailable);
    printf("\n");

    entry = (EimDomain *)((char *)list + list->firstEntry);
    for (i = 0; i < list->entriesReturned; i++)
    {
        printf("\n");
        printf("===============\n");
        printf("Entry %d.\n", i);
        
        /* Print out results */
        printListData("Domain Name",
                      entry,
                      offsetof(EimDomain, name));
        printListData("Domain dn",
                      entry,
                      offsetof(EimDomain, dn));
        printListData("description",
                      entry,
                      offsetof(EimDomain, description));

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

    }
    printf("\n");


}


void printListData(char * fieldName,
                   void * entry,
                   int offset)
{
    EimListData * listData;
    char * data;
    int dataLength;

    printf("     %s = ",fieldName);
    /* Address the EimListData object */
    listData = (EimListData *)((char *)entry + offset);
    
    /* Print out results */
    data = (char *)entry + listData->disp;
    dataLength = listData->length;
    
    if (dataLength > 0)
        printf("%.*s\n",dataLength, data);
    else
        printf("Not found.\n");
        
}



API introduced: V5R2

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