Thank you Arun,
I've looked at the code you posted:
If I understood well, debug goes into the first IF, does a "GetUserNameA()" and at the end of the code does a COMMIT and then hangs. (while there's no more code after that last IF ELSE ENDIF).
The only thing I'd worry about is the GetUserNameA() call. It passes ls_loginID, but without initializing ls_loginID. The API function GetUserNameA() needs a parameter "by ref" for the username, so that means it has to be initialized in PB. The second parameter is also by ref but that's a non-string parameter, so by having a value assigned to it, it's already initialized.
Try initializing ls_loginID at the beginning of the code (before doing any calls to GetUserName like this:
ls_loginID = Space(255)
Also:
You migrated from PB non-unicode 8.x to 11.x and then 2019. All pb versions, beginning with v. 10.x are Unicode, so that means the external API function declaration should preferrably be the Unicode versions (with "W" instead of "A"). The migration process should have added ";Ansi" to your GetUserNameA() function declaration, but ... :
Instead of using GetUsernameA(), use GetUsernameW():
function boolean GetUserNameW(ref string lpBuffer, ref ulong nSize) library "ADVAPI32.DLL"
See if that helps.
Regards.
MiguelL
----
Here it the code posted, but with indentation:
STRING ls_Access_Profile,ls_system_ip,ls_Access_Name,ls_host,ls_error
STRING ls_Audit_Name,ls_userName,ls_groupid,ls_GroupName,ls_createdby,ls_windowsUserid
Blob{4} lb_host
Integer li_version,li_Count
string ls_loginid,ls_Access_ID,ls_Audit_ID
ulong lul_value
boolean lb_rc
str_ws2 lstr_wsadata
IF as_option = 'Login' THEN
ls_host = Space(128)
li_version = 257
GetHost(g_computername, lb_host)
/*ls_system_ip = String(Asc(String(BlobMid(lb_host, 1, 1)))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 2, 1)))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 3, 1)))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 4, 1))))*/
//Commented and added by Backya-20.03.2020-Migartion changes-start
ls_system_ip = String(Asc(String(BlobMid(lb_host, 1, 1),EncodingANSI!))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 2, 1),EncodingANSI!))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 3, 1),EncodingANSI!))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 4, 1),EncodingANSI!)))
//Backya-20.03.2020-Migartion changes-start
SELECT levelname INTO :ls_Access_Profile
FROM ent_userlevels with (nolock)
WHERE levelid = :g_suserlevel USING SQLCA;
IF sqlca.sqlcode <> 0 THEN
ls_error = sqlca.sqlerrtext
Messagebox("Login - SplunkData(ent_userlevels)",ls_error)
END IF
SELECT username INTO :ls_Access_Name
FROM ent_users with (nolock)
WHERE userid = :g_sUser USING SQLCA;
IF sqlca.sqlcode <> 0 THEN
ls_error = sqlca.sqlerrtext
Messagebox("Login - SplunkData(ent_users)",ls_error)
END IF
lul_value = 255
lb_rc = GetUserNameA( ls_loginid, lul_value )
ls_Access_ID = g_sUser + "_" + ls_loginid
INSERT INTO Ent_ICCS_Splunk_LoginData
(Businessdate,Splunk_RefNumber,Access_ID,Access_Name,Access_Profile,Access_Type,
Access_Country,Access_SourceIP,Access_SourceHost,Access_LoginTimeStamp,Login_Export
)
VALUES
(:businessdate,:gs_splunk_refnbr,:ls_Access_ID,:ls_Access_Name,:ls_Access_Profile,'Desktop',
'AE',:ls_system_ip,:g_computername,getdate(),'N'
) USING SQLCA;
ELSEIF as_option = 'Logout' THEN
lul_value = 255
lb_rc = GetUserNameA( ls_loginid, lul_value )
ls_Access_ID = g_sUser + "_" + ls_loginid
UPDATE Ent_ICCS_Splunk_LoginData SET Access_LogoutTimeStamp = getdate(),Login_Export = 'N'
WHERE Access_ID = :ls_Access_ID
AND Splunk_RefNumber = :gs_splunk_refnbr USING SQLCA;
IF sqlca.sqlcode = 0 THEN
COMMIT USING SQLCA;
ELSE
ls_error = sqlca.sqlerrtext
Messagebox("Logout - SplunkData(ent_users)",ls_error)
END IF
/*
SELECT Count(1) INTO :li_Count
FROM Ent_ICCS_Splunk_LoginData with(nolock)
WHERE Access_ID = :g_sUser
AND Splunk_RefNumber = :gs_splunk_refnbr
AND isnull(Login_Export,'N') = 'N'
USING SQLCA;
IF li_Count > 0 THEN
UPDATE Ent_ICCS_Splunk_LoginData SET Access_LogoutTimeStamp = getdate()
WHERE Access_ID = :g_sUser
AND Splunk_RefNumber = :gs_splunk_refnbr USING SQLCA;
IF sqlca.sqlcode = 0 THEN
COMMIT USING SQLCA;
ELSE
ls_error = sqlca.sqlerrtext
Messagebox("Logout - SplunkData(ent_users)",ls_error)
END IF
ELSE
INSERT INTO Ent_ICCS_Splunk_LoginData
(Businessdate,Splunk_RefNumber,Access_ID,Access_Name,Access_Profile,Access_Type,
Access_Country,Access_SourceIP,Access_SourceHost,Access_LoginTimeStamp,Access_LogoutTimeStamp,Login_Export
)
SELECT Businessdate,Splunk_RefNumber,Access_ID,Access_Name,Access_Profile,Access_Type,
Access_Country,Access_SourceIP,Access_SourceHost,Access_LoginTimeStamp,getdate(),'N'
FROM Ent_ICCS_Splunk_LoginData with(nolock)
WHERE Access_ID = :g_sUser
AND Splunk_RefNumber = :gs_splunk_refnbr
AND isnull(Login_Export,'N') = 'Y'
USING SQLCA;
END IF
*/
ELSEIF as_option = 'Audit_History' THEN
ls_host = Space(128)
li_version = 257
GetHost(g_computername, lb_host)
/*ls_system_ip = String(Asc(String(BlobMid(lb_host, 1, 1)))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 2, 1)))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 3, 1)))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 4, 1))))*/
//Added by Backya-20.03.2020-Migartion changes-start
ls_system_ip = String(Asc(String(BlobMid(lb_host, 1, 1),EncodingANSI!))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 2, 1),EncodingANSI!))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 3, 1),EncodingANSI!))) + "."
ls_system_ip += String(Asc(String(BlobMid(lb_host, 4, 1),EncodingANSI!)))
//Added by Backya-20.03.2020-Migartion changes-end
SELECT username INTO :ls_Audit_Name
FROM ent_users with (nolock)
WHERE userid = :g_sUser USING SQLCA;
IF sqlca.sqlcode <> 0 THEN
ls_error = sqlca.sqlerrtext
Messagebox("Audit_History - SplunkData(ent_users)",ls_error)
END IF
lul_value = 255
lb_rc = GetUserNameA( ls_loginid, lul_value )
ls_Audit_ID = g_sUser + "_" + ls_loginid
INSERT INTO Ent_ICCS_Splunk_Audit_HistoryData
(Businessdate,Splunk_RefNumber,Audit_ID,Audit_Name,Audit_Status,Access_SourceIP,
Access_SourceHost,Audit_Country,Audit_LoginTimeStamp,Audit_Status_Export
)
VALUES
(:businessdate,:gs_splunk_refnbr,:ls_Audit_ID,:ls_Audit_Name,:as_loginstatus,:ls_system_ip,
:g_computername,'AE',getdate(),'N'
) USING SQLCA;
ELSEIF as_option = 'ID_Management' THEN
//RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\ACCS\","LoginId",RegString!,ls_loginid)
SELECT username,levelid,CASE WHEN :as_idmanagement_status = 'Create' THEN CreatedBy ELSE LastModifiedBy END,CreatedUser_WUserID
INTO :ls_userName,:ls_groupid,:ls_createdby,:ls_windowsUserid
FROM ent_users with(nolock)
WHERE userid = :as_idmanagement_userid USING SQLCA;
IF sqlca.sqlcode <> 0 THEN
ls_error = sqlca.sqlerrtext
Messagebox("ID_Management - SplunkData(ent_users)",ls_error)
END IF
ls_createdby = ls_createdby + "_" + ls_windowsUserid
SELECT levelname INTO :ls_GroupName
FROM ent_userlevels with (nolock)
WHERE levelid = :ls_groupid USING SQLCA;
IF sqlca.sqlcode <> 0 THEN
ls_error = sqlca.sqlerrtext
Messagebox("ID_Management - SplunkData(ent_userlevels)",ls_error)
END IF
INSERT INTO Ent_ICCS_Splunk_ID_Management
(Businessdate,Splunk_RefNumber,AppID_ID,AppID_Profile,AppID_Name,AppID_Type,AppID_Implemented_By,
AppID_Implemented_TimeStamp,AppID_Group,AppID_Status,AppID_Country,ID_Management_Export
)
VALUES
(:businessdate,:gs_splunk_refnbr,:as_idmanagement_userid,:ls_groupid,:ls_GroupName,'',:ls_createdby,
getdate(),'',:as_idmanagement_status,'AE','N'
) USING SQLCA;
ELSEIF as_option = 'Profile_Management' THEN
SELECT levelname,CASE WHEN :as_idmanagement_status = 'Create' THEN createdby ELSE ModifiedBy END,Windows_UserID
INTO :ls_groupName,:ls_createdby,:ls_windowsUserid
FROM ent_userlevels WITH(NOLOCK)
WHERE levelid = :as_idmanagement_userid USING SQLCA;
IF sqlca.sqlcode <> 0 THEN
ls_error = sqlca.sqlerrtext
Messagebox("Profile_Management - SplunkData(ent_userlevels)",ls_error)
END IF
ls_createdby = ls_createdby + "_" + ls_windowsUserid
INSERT INTO Ent_ICCS_Splunk_Profile_Management
(Businessdate,Splunk_RefNumber,Group_ID,Group_Name,Group_Type,
Group_Implemented_By,Group_Implemented_TimeStamp,Group_Status,
Group_Country,Profile_Management_Export
)
VALUES
(:businessdate,:gs_splunk_refnbr,:as_idmanagement_userid,:ls_groupName,'',
:ls_createdby,getdate(),:as_idmanagement_status,
'AE','N'
) USING SQLCA;
END IF
IF sqlca.sqlcode = 0 THEN
COMMIT USING SQLCA;
ELSE
ls_error = sqlca.sqlerrtext
ROLLBACK USING SQLCA;
Messagebox(as_option + ': SplunkData Error',ls_error)
END IF
Kind regards,
MiguelL
Its okay no issue... i have changed my interface from ADO>net to SQL native client it is solved..Thank you!
Regards
Backya