Highlighted
Regular Contributor.
Regular Contributor.
195 views

Efficient way to get owner id for a filename in cobol program

For security, want to retrieve files from a directory by owner ID (%username%)

0 Likes
4 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Efficient way to get owner id for a filename in cobol program

Good morning.

Have you tried with:

ACCEPT TERMINAL-ABILITIES FROM TERMINAL-INFO
ACCEPT SYSTEM-INFORMATION FROM SYSTEM-INFO

 See Format 3 (ACCEPT FROM), Steps 7 and 8.

 You will obtain useful information, either you are executing your program locally (wrun32.exe/runcbl) or via Thin Client.

If you want to inquire information about the files themselves, you can use C$FILEINFO, or CALL a Windows API such as KERNEL32.DLL and use one of its modules.

----------------------------
Claudio Contardi
Product Support Engineer, Senior
Micro Focus
0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Re: Efficient way to get owner id for a filename in cobol program

C$fileinfo would be good except returns only date time and file size, I believe.

Not familiar with calling api's in a cobol application

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Betreff: Efficient way to get owner id for a filename in cobol program

Hi,

i would use WMI.
It is easy to use with cobol as OLE Programming.. like accessing word, excel and so on.
i also have a example here in the forum how i do a ping with wmi in cobol.

TO use WMI u need to create a .def File with AXDEFGEN.
The needed object is for WMI then the @WbemScripting

The next i would use this Example https://devblogs.microsoft.com/scripting/how-can-i-determine-the-owner-of-a-file/ to convert it to a cobol code.

Greetings
David

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Betreff: Efficient way to get owner id for a filename in cobol program

I would probably use C$SYSTEM and run an operating system command:

Windows: DIR /Q *.* >mytempfile

Unix: ls -l * >mytempfile

Then read in the text file "mytempfile".  Extract the user id from the line and choose to use it or read next.  Then after I close that temporary file, I use the "DELETE FILE" command.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.