Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
sivakumar1994
New 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
else
'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

 

Next

'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
Else
strFileProps = strFileProps & "Couldn't retrieve security descriptor."
End If

Else
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');

 

1 Reply
Support
Support

Re: Identification of file owner name in Network server

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.  

Regards,
Brett

To help users find verified answers, please don't forget to mark a correct resolution or answer to your problem or question as correct.