FreeRadius with Informix
Posted in 2015
Topics: Connectivity: ODBC / JDBC / .NET, Platform-Specific Issues
Hi I used Freeradius open source talking with IBM Informix 11.2 on RH Linux 6.2 platform. It used for authentication. During testing I got problem with the below error message during executing the below SQL : expand: select count(*) from failed where username='%{User-Name}' and current - authdate < 10 UNITS MINUTE rlm_sql_unixodbc: 07009 [unixODBC][Informix][Informix ODBC Driver]Invalid descriptor index I just want to know what does it mean ?. Base on above simple query what/where could be the cause of error?. Appreciate some help from the expert. //
This corresponds to the Informix error -11103. Finderr reports:
$ finderr 11103-11103 Invalid descriptor index
This IBM Informix ODBC error code is the same as SQLSTATE value 07009.
The following functions can return this error code: SQLBindCol,
SQLBindParameter, SQLBulkOperations, SQLColAttribute, SQLDescribeCol,
SQLFetch, SQLFetchScroll, SQLGetData, SQLGetDescField, SQLGetDescRec,
SQLSetDescField, SQLSetDescRec, and SQLSetPos.
For SQLBindCol, SQLBindParameter, SQLColAttribute, SQLGetData, and
SQLDescribeCol, the value specified for column exceeded the maximum
number of columns in the result set.
For SQLBulkOperations, the argument Operation was SQL_ADD, and a column was
bound with a column number greater than the number of columns in the result
set.
For SQLFetch, the driver was an ODBC 2.x driver that does not support
SQLExtendedFetch, and a column number specified in the binding for a
column was 0.
For SQLFetchScroll, Column 0 was bound, and the SQL_ATTR_USE_BOOKMARKS
statement attribute was set to SQL_UB_OFF.
For SQLSetDescField and SQLGetDescField, the RecNumber argument was equal
to 0, the SQL_ATTR_USE_BOOKMARK statement attribute was SQL_UB_OFF, and the
DescriptorHandle argument was an IRD handle. (This error can be returned
for an explicitly allocated descriptor only if the descriptor is associated
with a statement handle.) The FieldIdentifier argument was a record field,
the RecNumber argument was 0, and the DescriptorHandle argument was an IPD
handle. The RecNumber argument was less than 0.
For SQLSetDescRec and SQLGetDescRec, the FieldIdentifier argument was a
record field, the RecNumber argument was set to 0, and the DescriptorHandle
argument was an IPD handle. The RecNumber argument was set to 0, the
SQL_ATTR_USE_BOOKMARKS statement attribute was set to SQL_UB_OFF, and the
DescriptorHandle argument was an IRD handle.(DM) The RecNumber argument was
less than 0.
For SQLSetPos, the argument Operation was SQL_REFRESH or SQL_UPDATE, and a
column was bound with a column number greater than the number of columns in
the result set.
Art
Art S. Kagel, President and Principal Consultant
ASK Database Management
www.askdbmgt.com
Blog: http://informix-myview.blogspot.com/
Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on the IIUG, nor any other organization with which I am
associated either explicitly, implicitly, or by inference. Neither do
those opinions reflect those of other individuals affiliated with any
entity with which I am affiliated nor those of the entities themselves.
On Mon, May 18, 2015 at 7:02 AM, SYED AHMAD NAJMI SYED MD NASIR <
najmi@centurysoftware.com.my> wrote:
> Hi
>
> I used Freeradius open source talking with IBM Informix 11.2 on RH Linux
> 6.2
> platform.
>
> It used for authentication.
>
> During testing I got problem with the below error message during executing
> the
> below SQL :
>
> expand: select count(*) from failed where username='%{User-Name}' and
> current
> - authdate < 10 UNITS MINUTE
>
> rlm_sql_unixodbc: 07009 [unixODBC][Informix][Informix ODBC Driver]Invalid
> descriptor index
>
> I just want to know what does it mean ?. Base on above simple query
> what/where
> could be the cause of error?.
>
> Appreciate some help from the expert.
>
> //
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--90e6ba5bb94fc22dee0516597257
Hi It is expected to work. Assuming a table with these columns and also more. "CREATE TABLE failed ( username char(20), current DATE, authdate DATE);= " Then you are executing the SQL like this rc =3D SQLExecDirect(Stmt, "select count(*) from failed where username=3D'%{User-Name}' and current - authdate < 10 UNITS MINUTE", SQL_NTS); Call the GetDiagRec soon after you got the failure as shown bellow GetDiagRec ( rc, SQL_HANDLE_STMT, Stmt, "Select" ); Will you be able to capture more error information. The GetDiagRec function give bellow is a sample code where it can capture more error information. Please let me know the error output printing with that. void GetDiagRec(SQLRETURN rc, SQLSMALLINT htype, SQLHANDLE hndl, char *szMsgTag ) { SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1]; SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; SQLINTEGER sqlcode=3D0; SQLSMALLINT length=3D0; if ( szMsgTag =3D=3D NULL ) { szMsgTag =3D "---"; } printf( "\\ %s: %d : ", szMsgTag, rc); if (rc >=3D 0) { printf( " OK [rc=3D%d] \\ ", rc); } else { int i=3D1; printf( " FAILED : %i", rc); while (SQLGetDiagRec(htype, hndl, i, sqlstate, &sqlcode, message, SQL_MAX_MESSAGE_LENGTH + 1, &length) =3D=3D SQL_SUCCESS) { printf( "\\ SQLSTATE =3D %s", sqlstate); printf( "\\ Native Error Code =3D %ld", sqlcode); printf( "\\ %s", message); i++; } printf( "\\ -------------------------\\ "); } } Regards, Satyan Advisory Software Engineer R&D - IBM Information Management Division 11200 Lakeview, Lenexa, KS 66219 Tel: 913 599 8792 (T/L: 337-8792) From: "SYED AHMAD NAJMI SYED MD NASIR" <najmi@centurysoftware.com.my> To: ids@iiug.org Date: 05/18/2015 06:03 AM Subject: FreeRadius with Informix [35116] Sent by: ids-bounces@iiug.org Hi I used Freeradius open source talking with IBM Informix 11.2 on RH Linu= x 6.2 platform. It used for authentication. During testing I got problem with the below error message during execut= ing the below SQL : expand: select count(*) from failed where username=3D'%{User-Name}' and= current - authdate < 10 UNITS MINUTE rlm_sql_unixodbc: 07009 [unixODBC][Informix][Informix ODBC Driver]Inval= id descriptor index I just want to know what does it mean ?. Base on above simple query what/where could be the cause of error?. Appreciate some help from the expert. // ***********************************************************************= ******** Forum Note: Use "Reply" to post a response in the discussion forum. =
Two quick questions.
I believe in the select statement you might need to prepend the table name
to the column named
"current". As current is a reserved word and the parser will not
understand if you want the
current column or the current keyword. Using the table.column will clear
this up. Do you really mean
to have a column current, or do you really want the "CURRENT" date and
time??
Second I am not sure if the "current" and "authdate" columns should be date
or datetime, as subtracting
two dates will only be less than 10 minutes if they are the same date.
I am just guessing but I think the table needs to look like the following.
CREATE TABLE failed ( username char(20), authdate DATETIME YEAR TO SECOND)
John F. Miller III
STSM, Lead Architect
miller3@us.ibm.com
503-747-1366
IBM Informix Dynamic Server (IDS)
ids-bounces@iiug.org wrote on 05/18/2015 08:35:15 AM:
> From: Sathyanesh Krishnan/Lenexa/IBM@IBMUS
> To: ids@iiug.org
> Date: 05/18/2015 08:36 AM
> Subject: Re: FreeRadius with Informix [35121]
> Sent by: ids-bounces@iiug.org
>
> Hi
>
> It is expected to work.
>
> Assuming a table with these columns and also more.
> "CREATE TABLE failed ( username char(20), current DATE, authdate DATE);=
> "
>
> Then you are executing the SQL like this
> rc =3D SQLExecDirect(Stmt,
> "select count(*) from failed where username=3D'%{User-Name}' and
> current - authdate < 10 UNITS MINUTE", SQL_NTS);
>
> Call the GetDiagRec soon after you got the failure as shown bellow
> GetDiagRec ( rc, SQL_HANDLE_STMT, Stmt, "Select" );
>
> Will you be able to capture more error information.
> The GetDiagRec function give bellow is a sample code
> where it can capture more error information.
> Please let me know the error output printing with that.
>
> void GetDiagRec(SQLRETURN rc, SQLSMALLINT htype,
>
> SQLHANDLE hndl, char *szMsgTag )
> {
>
> SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1];
>
> SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1];
>
> SQLINTEGER sqlcode=3D0;
>
> SQLSMALLINT length=3D0;
>
> if ( szMsgTag =3D=3D NULL )
>
> {
>
> szMsgTag =3D "---";
>
> }
>
> printf( "\\
%s: %d : ", szMsgTag, rc);
>
> if (rc >=3D 0)
>
> {
>
> printf( " OK [rc=3D%d] \\
", rc);
>
> }
>
> else
>
> {
>
> int i=3D1;
>
> printf( " FAILED : %i", rc);
>
> while (SQLGetDiagRec(htype,
>
> hndl,
>
> i,
>
> sqlstate,
>
> &sqlcode,
>
> message,
>
> SQL_MAX_MESSAGE_LENGTH + 1,
>
> &length) =3D=3D SQL_SUCCESS)
>
> {
>
> printf( "\\
SQLSTATE =3D %s", sqlstate);
>
> printf( "\\
Native Error Code =3D %ld", sqlcode);
>
> printf( "\\
%s", message);
>
> i++;
>
> }
>
> printf( "\\
-------------------------\\
");
>
> }
> }
>
> Regards,
> Satyan
>
> Advisory Software Engineer
> R&D - IBM Information Management Division
> 11200 Lakeview, Lenexa, KS 66219
> Tel: 913 599 8792 (T/L: 337-8792)
>
> From: "SYED AHMAD NAJMI SYED MD NASIR" <najmi@centurysoftware.com.my>
> To: ids@iiug.org
> Date: 05/18/2015 06:03 AM
> Subject: FreeRadius with Informix [35116]
> Sent by: ids-bounces@iiug.org
>
> Hi
>
> I used Freeradius open source talking with IBM Informix 11.2 on RH Linu=
> x
> 6.2
> platform.
>
> It used for authentication.
>
> During testing I got problem with the below error message during execut=
> ing
> the
> below SQL :
>
> expand: select count(*) from failed where username=3D'%{User-Name}' and=
>
> current
> - authdate < 10 UNITS MINUTE
>
> rlm_sql_unixodbc: 07009 [unixODBC][Informix][Informix ODBC Driver]Inval=
> id
> descriptor index
>
> I just want to know what does it mean ?. Base on above simple query
> what/where
> could be the cause of error?.
>
> Appreciate some help from the expert.
>
> //
>
> ***********************************************************************=
> ********
>
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
> =
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
Hi
Thanks all for respond.
The table failed is used to store the login attempt with wrong password. When
the attempt count reached a max number ;eg. 5 counts between 10 minutes, the
user will get lockout although he enter a correct password on next attempt.
This feature is not built in standard FreeRadius installation. But it allow to
add in.
Here is the table structure :-
create table "informix".failed
(
username varchar(64),
authdate datetime year to fraction(3)
);
revoke all on "informix".failed from "public" as "informix";
create index "informix".ix_rad01 on "informix".failed (username)
using btree ;
Everytime there was failed attempt with wrong password, there is sql that will
do insert in this table with values (username, current). The insert sql is
fine. Just I have a problem with select count(*) to calculate the number of
existing record. I only have few records in that table( less than 10).
I able to execute the query directly via dbaccess.
Thanks