[jcifs] Get the owner of a file, calculate MD5/SHA-1

Michael B Allen ioplex at gmail.com
Mon Jun 23 18:05:43 GMT 2008


On 6/23/08, Jürgen R. Plasser <juergen.plasser at gmail.com> wrote:
> Hi All,
>
>  how do I get the owner of a file? I need some code snippets, as I'm
>  new to JCIFS and CIFS at all.
>
>  I can get the ACLs from a file, and all I have understood until now is
>  that the owner is coded into a SID which has to be looked up
>  somewhere. I hope some can enlighten me ...

Currently we do not extract the owner SID from the security
descriptor. In SecurityDescriptor.java ~line 40:

  http://jcifs.samba.org/src/src/jcifs/smb/SecurityDescriptor.java

you can see the "offset to owner sid" is ignored. You would need to
add some code similar to how daclOffset is used but without the loop.

Then you would need to add a getOwnerSid method to SmbFile (that
should look very much like a simplified version of getSecurity)

>  My second question (is likely OT):
>  Is it possible to calculate the file's MD5 or SHA-1 hash without
>  copying it from the source, just by streaming?

An SmbFileInputStream is an instance of InputStream so if you can
compute a hash on an InputStream you can compute it with an
SmbFileInputStream.

Mike

-- 
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/


More information about the jcifs mailing list