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
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.