I think this forum has some ‘magic powers’…
It happened to me now quite a few times:
When I post a question on the forum (after a long search for an answer on the forum or internet or trying coding my self) after a few minutes it hits me.
In my OP I was using this manual Authentication Query in the database User source for retrieving RFID numbers:
declare @user varchar(50)
declare @rfid varchar(100)
declare @geslo varchar(100)
set @user = ?
set @geslo = ?
set @rfid = CASE WHEN @geslo <> '' THEN @geslo ELSE 'unknown' END
SELECT OPR_IME FROM
(SELECT *
FROM XMESQOPR
UNION ALL
SELECT '9999' AS MQOPR_ID,
'0' AS MQOPR_STA,
getdate() AS MQOPR_MSD,
'99999' AS OPR_SIF,
'User12' AS OPR_IME,
'5' AS OPR_AKT,
'user12' AS OPR_GES,
'99' AS OPR_LVL,
'user12' AS OPR_RFID1,
'user12' AS OPR_RFID2,
'user12' AS OPR_RFID3) AS p
WHERE OPR_IME = @user AND @rfid IN (OPR_RFID1,OPR_RFID2,OPR_RFID3) AND OPR_AKT = '5'
and for second database User source for use with passwords (manual login) I was using this (the diference is in the WHERE clause):
declare @user varchar(50)
declare @rfid varchar(100)
declare @geslo varchar(100)
set @user = ?
set @geslo = ?
set @rfid = CASE WHEN @geslo <> '' THEN @geslo ELSE 'unknown' END
SELECT OPR_IME FROM
(SELECT *
FROM XMESQOPR
UNION ALL
SELECT '9999' AS MQOPR_ID,
'0' AS MQOPR_STA,
getdate() AS MQOPR_MSD,
'99999' AS OPR_SIF,
'User12' AS OPR_IME,
'5' AS OPR_AKT,
'user12' AS OPR_GES,
'99' AS OPR_LVL,
'user12' AS OPR_RFID1,
'user12' AS OPR_RFID2,
'user12' AS OPR_RFID3) AS p
WHERE OPR_IME = @user AND @rfid = OPR_GES AND OPR_AKT = '5'
The ‘divine revelation’ that came to me was this (again in the WHERE clause):
declare @user varchar(50)
declare @rfid varchar(100)
declare @geslo varchar(100)
set @user = ?
set @geslo = ?
set @rfid = CASE WHEN @geslo <> '' THEN @geslo ELSE 'unknown' END
SELECT OPR_IME FROM
(SELECT *
FROM XMESQOPR
UNION ALL
SELECT '9999' AS MQOPR_ID,
'0' AS MQOPR_STA,
getdate() AS MQOPR_MSD,
'99999' AS OPR_SIF,
'User12' AS OPR_IME,
'5' AS OPR_AKT,
'user12' AS OPR_GES,
'99' AS OPR_LVL,
'user12' AS OPR_RFID1,
'user12' AS OPR_RFID2,
'user12' AS OPR_RFID3) AS p
WHERE OPR_IME = @user AND @rfid IN (OPR_GES,OPR_RFID1,OPR_RFID2,OPR_RFID3) AND OPR_AKT = '5'
I can put the password field (OPR_GES) in the same list with RFID fields and then it doesn’t matter what the @rfid (@geslo) is: RFID number from the scanned card or the password from the manual login. If it’s any of these fields, it’s OK; the user is authenticated, when you use system.security.switchUser.