Discussion:
Get users on a file share directory
(too old to reply)
Andre Crespo
2018-03-02 18:37:56 UTC
Permalink
Raw Message
Is there any way to get users who have access to a file server directory with TDI? TDI read this directory remotely.
Franzw
2018-03-04 19:51:55 UTC
Permalink
Raw Message
Post by Andre Crespo
Is there any way to get users who have access to a file server directory with TDI? TDI read this directory remotely.
Not directly.

There are a couple of possibilities to read the ACLs using Java and hence can be used in TDI. This was introduced in Java 7 so you may need to update your TDI JRE.

Be aware that Windows ACL (especially the inheritance) is NOT supported correctly in the Java ootb implementation - so you cannot do expect to receive the same level of information on Windows shares as you get in Windows natively.

I will see if I can dig up some samples to gt you started...

Regards
Franz Wolfhagen
Franzw
2018-03-08 13:27:08 UTC
Permalink
Raw Message
Post by Franzw
Post by Andre Crespo
Is there any way to get users who have access to a file server directory with TDI? TDI read this directory remotely.
Not directly.
There are a couple of possibilities to read the ACLs using Java and hence can be used in TDI. This was introduced in Java 7 so you may need to update your TDI JRE.
Be aware that Windows ACL (especially the inheritance) is NOT supported correctly in the Java ootb implementation - so you cannot do expect to receive the same level of information on Windows shares as you get in Windows natively.
I will see if I can dig up some samples to gt you started...
Regards
Franz Wolfhagen
As promised - here is something to look into - as mentioned this is not using the Windows native implementation but the open Java ones - this gives problems if you want to look at the inheritance which is not covered by the standard Java filesystem API...

Regards
Franz Wolfhagen

importPackage(Packages.java.nio.file);

myShares = ["\\\\192.168.42.226\\SharedFolder\\"]

//This is real work starting

if (myShares != null) {
task.logmsg(myShares)
for (i=0; i<myShares.length; i++){
myShare = myShares[i];
task.logmsg("***************************************************************************")
task.logmsg("Share : " + myShare)
//Getting the path object - needs to pass a null arg
var args = new Packages.java.lang.String[0];
myPath = Paths.get(myShare,args);
//task.logmsg(myPath.getRoot())
//task.logmsg(myPath.getNameCount())
myFileSystem = myPath.getFileSystem();
task.logmsg("Supported File Attribute Views" + myFileSystem.supportedFileAttributeViews())
var args = new Packages.java.nio.file.LinkOption[0];
task.logmsg("isDirectory : " + Files.isDirectory(myPath,args))
task.logmsg("Owner : " + Files.getAttribute(myPath, "acl:owner",args));

myClass = java.lang.Class.forName("java.nio.file.attribute.AclFileAttributeView")
view = Files.getFileAttributeView(myPath,myClass,args);
myAcls = view.getAcl();
for (myAcl in myAcls) {
//task.logmsg(myAcl)
task.logmsg("Prinipal ====== : " + myAcl.principal())
task.logmsg("Type ========== : " + myAcl.type())
task.logmsg("Flags ========= : " + myAcl.flags())
task.logmsg("Permissions === : " + myAcl.permissions())
}
/*
*
Set<AclEntryPermission> permissions()
Returns a copy of the permissions component.
UserPrincipal principal()
Returns the principal component.
AclEntryType type()
Returns the ACL entry type.
*
*/

}
} else {
task.logmsg("INFO","No shares found for " + host)
}

Loading...