Q:

Getting OCI_INVALID_HANDLE after OCILogon with OCI_SUCCESS_WITH_INFO

I have created following profile. 
create profile EXPTESTPROF limit failed_login_attempts unlimited password_life_time 1/24/60/60 password_reuse_time unlimited password_reuse_max unlimited password_verify_function null password_lock_time 1  password_grace_time 31;

alter user exptest profile EXPTESTPROF;

When i try to login from command prompt it logs in successfully with following error message. 

ERROR:
ORA-28002: the password will expire within 30 days

Till that I am fine. 
However I wrote one small program for OCI login and some actions. 
When I call OCILogon with the above user it returns 1 that addreses OCI_SUCCESS_WITH_INFO. 
After that I i trying to fetch OCI_HTYPE_SVCCTX using OCIAttrGet it returns -2 which addreses OCI_INVALID_HANDLE. 
Why handle is getting corrupted?  IS there any way to overcome this issue and work till grace period ends? 
Please find sample OCI client below. 
#include "stdio.h"
#include "oci.h"
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#pragma comment(lib, "%ORACLE_HOME%\\oci\\lib\\MSVC\\oci.lib")

void main()
{
  int    errcode   = 0;
  int    rc        = 0;
  sb4    ociErrVal = 0;
  char   *ErrTxt   = NULL;
  ub4    BufLen    = 1024;
  size_t DBNameLen = 0;
  size_t PasswdLen = 0;
  size_t UserLen   = 0;

  OCISvcCtx        *p_svc = NULL;
  OCIEnv           *p_env = NULL;
  OCIError         *p_err = NULL;
  OCIStmt          *p_sql = NULL;
  OCIDefine        *p_dfn = (OCIDefine *) 0;
  OCIBind          *p_bnd = (OCIBind *) 0;

  const unsigned char *UserID   = (const unsigned char*)"exptest";
  const unsigned char *Password = (const unsigned char*)"oracle";
  const unsigned char *DBName   = (const unsigned char*)"ORCL10G";

  if (UserID ! = NULL)
  {
      UserLen = strlen ((char *)UserID);
  }

  if (Password ! = NULL)
  {
      PasswdLen  = strlen((char *)Password);
  }

  if (DBName   ! = NULL)
  {
      DBNameLen = strlen((char *)DBName);
  }

  if (ErrTxt ! = NULL) {
      BufLen = 0;
      ErrTxt[0] = '\0';          
      ErrTxt[1] = '\0';          
      ErrTxt[2] = '\0';
      ErrTxt[3] = '\0';
   }

  rc = OCIInitialize((ub4) OCI_DEFAULT, (dvoid *)0,  /* Initialize OCI */
          (dvoid * (*)(dvoid *, size_t)) 0,
          (dvoid * (*)(dvoid *, dvoid *, size_t))0,
          (void (*)(dvoid *, dvoid *)) 0 );

  /* Initialize evironment */
  rc = OCIEnvInit( (OCIEnv **) &p_env, OCI_DEFAULT, (size_t) 0, (dvoid **) 0 );

  /* Initialize handles */
  rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_err, OCI_HTYPE_ERROR,
          (size_t) 0, (dvoid **) 0);
  rc = OCIHandleAlloc( (dvoid *) p_env, (dvoid **) &p_svc, OCI_HTYPE_SVCCTX,
          (size_t) 0, (dvoid **) 0);

  /* Connect to database server */
  rc = OCILogon(p_env, 
                p_err,
                &p_svc,
                UserID,
                (ub4) UserLen,
                Password,
                (ub4) PasswdLen,
                DBName,
                (ub4) DBNameLen);

  if (rc ! = 0) {
     OCIErrorGet((dvoid *)p_err,
                 (ub4) 1,
                 (text *) NULL,
                 &errcode,
                 (unsigned char *) ErrTxt,
                 BufLen,
                 OCI_HTYPE_ERROR);
   }

    rc = (long) OCIAttrGet(p_svc,
                         (ub4) OCI_HTYPE_SVCCTX,
                         (dvoid *) &p_svc,
                         (ub4) NULL,
                         (ub4) OCI_ATTR_SERVER,
                         p_err);

  rc = OCILogoff(p_svc, p_err);                           /* Disconnect */
  rc = OCIHandleFree((dvoid *) p_sql, OCI_HTYPE_STMT);    /* Free handles */
  rc = OCIHandleFree((dvoid *) p_svc, OCI_HTYPE_SVCCTX);
  rc = OCIHandleFree((dvoid *) p_err, OCI_HTYPE_ERROR);
}

A:

The issue is in OCI Api's and it is been fixed in oracle11g R2 – 

