Connect handler

The connect handler can be used to authenticate the connection’s user name. Users must be validated based on user name/password, and you must supply code for password maintenance and checking.

Notesrv_thread_props(SRV_T_USERDATA) is off-limits to EAServer programmers.

The following is an example of a connect handler that logs the user name, password, and locale name when a connection is opened:

CS_RETCODE CS_PUBLIC
debug_connect(srvproc)
SRV_PROC    *srvproc;
{
    CS_INT      spid;
    CS_INT      ulen;
    CS_INT      plen;
    CS_INT      llen;
    CS_CHAR     msg[CS_MAX_MSG];
    CS_CHAR     user[CS_MAX_NAME+1];
    CS_CHAR     password[CS_MAX_NAME+1];
    /* Initialization                           */
    spid = 0;
    /* Get the spid    */
    if (srv_thread_props(srvproc, CS_GET, SRV_T_SPID, 
        (CS_VOID *)&spid,
        CS_SIZEOF(spid), NIL(CS_INT *)) != CS_SUCCEED)
    {
        return (CS_FAIL);
    }
    /*
    ** Get the username and password
    */
    if (srv_thread_props(srvproc, CS_GET, SRV_T_USER, 
        (CS_VOID *)user,
        CS_MAX_NAME, &ulen) != CS_SUCCEED)
    {
        return (CS_FAIL);
    }
    if (srv_thread_props(srvproc, CS_GET, SRV_T_PWD, 
           (CS_VOID *)password,
           CS_MAX_NAME, &plen) != CS_SUCCEED)
    {
        return (CS_FAIL);
    }
    /* Null terminate the username and password      */
    user[ulen] = (CS_CHAR)’\0’;
    password[plen] = (CS_CHAR)’\0’;
    /* Log the username and password values.    */
    sprintf(msg,"SPID %d) user ’%s’, password ’%s’\n",
            spid, user, password);
    SRV_LOG(CS_TRUE, msg, CS_NULLTERM);
    return (CS_SUCCEED);
}