eimConnect
Purpose
Connects to the EIM domain.
Format
#include <eim.h>
int eimConnect(EimHandle * eim,
EimConnectInfo connectInfo,
EimRC * eimrc)
Parameters
- eim
- (Input) The EIM handle that a previous call to eimCreateHandle returns.
- connectInfo
- (Input) Connect information. 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 the EIM_SIMPLE connect type, the creds field should contain the EimSimpleConnectInfo structure with a binddn and password.
If the connect type is EIM_SIMPLE and you provide no binddn or password, the connection information extracted from the RACF database during the eimCreateHandle API call is used.Note: Both the bindDn and bindPw must be NULL. Also, the previous call to eimCreateHandle must have been made with a NULL ldapURL in order for eimCreateHandle to have extracted the information from the RACF database. The resulting handle should then be used with eimConnect. If the ldapURL was not NULL, then no information was extracted from the RACF database and a NULL bindDn and bindPw will result in an EIMERR_PARM_REQ error.EimPasswordProtect determines 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. The ssl field must point to a valid EimSSLInfo structure. The keyring field is required in the EimSSLInfo structure. It can be the name of a System SSL key database file or a RACF keyring name. The keyring_pw field is required when the keyring is the name of a System SSL key database field. The certificateLabel field is optional. If it is NULL the default certificate in the keyring is used.
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; - eimrc
- (Input/Output) The structure in which to return error code information. If the return value is not 0, EIM sets eimrc with additional information. This parameter can be NULL. For the format of the structure, see EimRC -- EIM return code parameter for C/C++.
Related Information
Authorization
- z/OS authorization
- The calling application can be running in system key or supervisor
state or one of the following:
- The RACF user ID of the caller's address space has READ access to the BPX.SERVER profile in the FACILITY class
- The current RACF user ID has READ authority to the IRR.RDCEKEY profile in the FACILITY class
Return Values
| Return Value | Meaning |
|---|---|
| 0 | Request was successful. |
| EACCES | Access denied. Not enough permissions to access data. |
| EBADDATA | eimrc is not valid. |
| EBUSY | Unable to allocate internal system
object.
|
| ECONVERT | Data conversion error.
|
| EINVAL | Input parameter was not valid.
|
| EISCONN | A connection has already been established.
|
| EMVSSAFEXTRERR | A connection has already been established.
|
| EMVSSAF2ERR | SAF/RACF error
|
| ENOMEM | Unable to allocate required space.
|
| ENOTSUP | Connection type is not supported.
|
| EUNKNOWN | Unexpected exception.
|
Example
#include <eim.h>
#include <string.h>
.
.
.
int rc;
char eimerr[200];
EimRC * err;
EimHandle handle;
EimConnectInfo con;
/* Set up error structure. */
memset(eimerr,0x00,200);
err = (EimRC *)eimerr;
err->memoryProvidedByCaller = 200;
/* 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;
.
.
.
/* Connect to LDAP URL defined by handle with specified connection credentials */
rc = eimConnect(&handle, con, err);
.
.
.
#include <eim.h>
#include <string.h>
.
.
.
int rc;
char eimerr [200];
EimRC *err;
EimHandle handle;
EimConnectInfo con;
/*Set up error structure.*/
memset(eimerr,0x00,200);
err =(EimRC *)eimerr;
err->memoryProvidedByCaller =200;
/*Create new eim handle for a specified ldapURL */
ldapURL ="ldap://eimsystem:389/ibm-eimDomainName=myEimDomain,o=mycompany,c=us";
rc =eimCreateHandle(&handle,ldapURL,err);
.
.
.
/*Set up connection information */
memset(&con, 0x00, sizeof(con));
con.type =EIM_KERBEROS;
/*Connect to LDAP URL defined in handle with the specified connection credentials*/
rc =eimConnect(&handle,con,err);
.
.
.