1. Ganaesu S
  2. PowerBuilder
  3. Monday, 15 July 2024 17:32 PM UTC

Hello

We are having an issue with our desktop application crashing only in VMware when the User's have a long samAccountName (18 or more characters). Same user's are able to run the same App in Citrix or Desktop without any issues.

Rest of the user's have no issues.

Application was build in PB 2022 R3 Build 3356 application.

Any help is appreciated

 

Thanks

G

Accepted Answer
Ganaesu S Accepted Answer Pending Moderation
  1. Wednesday, 24 July 2024 13:53 PM UTC
  2. PowerBuilder
  3. # Permalink

FYI

after fighting for couple of weeks came up 2 solutions

1st one was to prefill UserName with 64 "X" characters or any characters

2nd one - removed the API call, but the drawback is for the User to enter their Login credentials every time

Comment
  1. John Fauss
  2. Wednesday, 24 July 2024 15:45 PM UTC
If by "prefill UserName" you mean you have to initialize the string variable that the GetUserNameW API function returns, then Yes, you MUST perform this initialization, as Roland showed in the code snippet he provided.

Any buffer passed to a Windows API function that gets assigned a value by the API function must always first be initialized by the PB application to its maximum length before the API function is called. Typically, this is easily done in PB via the Space PowerScript function, as Roland's code shows.

In this particular case, the GetUserNameW API expects the buffer to be 257 characters long (256 usable characters plus a string-terminating null character). The UNLEN (User Name LENgth) constant has the value 256, and the code adds 1 for the terminating null. This is clearly described in the Windows API documentation for the GetUserNameW function:

https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getusernamew

As stated in the above documentation link, the UNLEN constant is defined in the C/C++ header file named lmcons.h. This is where Roland determined the proper value for this constant.
  1. Helpful
  1. Ganaesu S
  2. Wednesday, 24 July 2024 16:05 PM UTC
I got the same error, when the ls_username was initialized with spaces or blank
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 17 July 2024 12:43 PM UTC
  2. PowerBuilder
  3. # 1

Change your GetUserName code to look like this:

Function boolean GetUserName ( &
	Ref string lpBuffer, &
	Ref ulong pcbBuffer &
	) Library "advapi32.dll" Alias For "GetUserNameW"


Constant ULong UNLEN = 256
Boolean lb_Result
String ls_UserName
ULong lul_BufSize

lul_BufSize = UNLEN + 1
ls_UserName = Space(lul_BufSize)

lb_Result = GetUserName(ls_UserName, lul_BufSize)

 

Comment
  1. Ganaesu S
  2. Wednesday, 17 July 2024 12:56 PM UTC
Thanks Roland,

Appreciate the code help

I will try and let you know
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Wednesday, 17 July 2024 05:42 AM UTC
  2. PowerBuilder
  3. # 2

I think you have to find out the code that causes you application to crash. Maybe someone can help you if you could show this part here.

A possible reason could be that a buffer is to small for an API call.

You should also think about change from GetUserNameA to GetUserNameW.

Comment
  1. Ganaesu S
  2. Wednesday, 17 July 2024 12:56 PM UTC
I have tried both GetUserNameA & GetUserNameW, same results

Will try the buffer option.. thanks
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 16 July 2024 16:38 PM UTC
  2. PowerBuilder
  3. # 3

What kind of database server are you connecting to and what db interface are you using?

Are you using Windows Authentication? That is the only way PowerBuilder might be interfacing with Active Directory.

Comment
  1. Ganaesu S
  2. Tuesday, 16 July 2024 17:46 PM UTC
Hi Roland,

We use DB2.

App requires a 8 char User ID (same as Network logon ID) & password. That ID is used for DB2 authentication

I call GetUserNameA to check whether User is coming thru Desktop, Citrix or VMWare to differentiate the logon process.

If Desktop or Citrix, then I populate the User ID (same as network login ID).

if VMware, then I populate the User ID as "XXXXXXXX", because user's log into VMWare client using their first name.last name credentiais





  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 15 July 2024 18:05 PM UTC
  2. PowerBuilder
  3. # 4

Hi, Ganaesu -

Why do you suspect/believe this is a PowerBuilder problem? From your description, it seems more likely that this is a VMWare-related issue.

Best regards, John

Comment
  1. Ganaesu S
  2. Monday, 15 July 2024 18:17 PM UTC
Hi John,

I am not suspecting this is a PB or my application problem, but the VM team & network admins insist this is related to either the App or PB



thanks

G
  1. Helpful
  1. John Fauss
  2. Tuesday, 16 July 2024 16:04 PM UTC
Unless you are manipulating LDAP settings directly from your PB application, it should not have any interaction with samAccountName, which dates back to Windows NT 4.0 according to the information I've seen on the web. From what I have seen, the samAccountName property was functionally replaced long ago by the User Principal Name (UPN). Do the user's experiencing this issue have a UPN defined?

Was your PB app migrated from an earlier version of PB that was working? If so, what version/release/build? What database(s) and Transaction Object properties are being used?

If the app works correctly under Citrix or on the desktop, what specific reason(s) do your VMWare and Network Admins give to back up their insistence that this is a PB or application issue? I suspect you will have to provide additional details as to what your app is doing and also the reasons why your support teams and not willing to support you in troubleshooting this issue.
  1. Helpful
  1. Ganaesu S
  2. Tuesday, 16 July 2024 17:36 PM UTC
I am not manipulating LDAP settings. Not sure about UPN settings, will check

We migrated PB from 2019 to 2022, but we started testing VMWare only in PB 2022

We use DB2 via SQLCA

VM team & Network team think it is related to the App - They are not giving any specific reasons!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.