Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Read about the latest Qlik Community enhancements on the Community News blog!
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

Identification of file owner name in Network server

Hi All,

I was unable to identify the owner of a file in a network server but i was able to access the owner name of a file in local system using below macro.



Function strFileProps (File)

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(File) Then
Set objFile = objFSO.GetFile(File)

tmp2 = objFile.Name 'for shell32 code

tmp = objFile.ParentFolder 'for shell32 code

if objFile.attributes and 1 then
'strFileProps = strFileProps & "Read-Only: YES" & VbCrLf
'strFileProps = strFileProps & "Read-Only: NO" & VbCrLf
End If

'get additional file details via shell32.dll
set shell = CreateObject("Shell.Application")
set objFolder = shell.NameSpace(tmp)
set objFolderItems = objFolder.Items()

For Each objItem in objFolderItems

If objItem = tmp2 then

strFileProps = strFileProps& objFolder.GetDetailsOf(objItem,8) & VbCrLf

End If



'get owner- alternative method
Set objWMIService = getObject("winmgmts:")
Set objFileSecuritySettings = objWMIService.Get("Win32_LogicalFileSecuritySetting='" & File & "'")
intRetVal = objFileSecuritySettings.GetSecurityDescriptor(objFile)

If intRetVal = 0 Then
strFileProps = strFileProps & objFile.Owner.Name
strFileProps = strFileProps & "Couldn't retrieve security descriptor."
End If

strFileProps = "Selected file does not exist!"
End If

End Function


//Macro is working for below statement refering local file

LET AttributeX = strFileProps('C:\Temp\task1.doc');


//Where as below command is not working which was referring file in a network server (note: no connectivity or access issue to the network server and the network server files )

LET AttributeX = strFileProps('\\Server1\Folder1\Temp\task1.doc');


Labels (5)
1 Reply
Support (Former)
Support (Former)

Please note, all the API calls you are making here are system APIs, not Qlik APIs, therefore asking about this on these forums is not likely going to get you any answers.  You are likely better served going to a Microsoft forum for this, as the APIs you are using are theirs.  

One potential issue may be the Edit Module's VB version, it is quite an early version that has/will not be further updated, so it may just be something that cannot be handled by the underlying editor, but again, I would suspect you are more likely to find an answer to this on a Microsoft Forum in this case.  Another place to check though may be Stack Overflow, might be something out there potentially too.  


To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.