[jcifs] canWrite() question

Michael B Allen mba2000 at ioplex.com
Fri Aug 11 20:04:18 GMT 2006


The canWrite and canRead methods are somewhat useless. They just check the
"Read only" bit of the file attributes. JCIFS does not inspect a file's
ACL and perform an access check using the identity of the current user. We
don't integrate properly with Java's Subject based security model.

The only way to tell if you can write a file is to actually try and open
it for writing with new SmbFileOutputStream.

Mike

On Fri, 11 Aug 2006 19:20:17 +0000 (UTC)
Roger Thomas <rthomas at stone-ware.com> wrote:

> Test JSP....
> 
> <%@page import="jcifs.smb.*"%>
> <%
> 
> jcifs.Config.setProperty( "jcifs.netbios.wins", "10.1.1.26" );
> 
> SmbFile f1 = new SmbFile( "smb://administrator@10.1.1.10/c$" );
> System.out.println( "c$ " + f1.canWrite() );
> 
> SmbFile f2 = new SmbFile( "smb://administrator@10.1.1.10/c$/" );
> System.out.println( "c$ " + f2.canWrite() );
> 
> SmbFile f3 = new SmbFile( "smb://administrator@10.1.1.10/c$/movies" );
> System.out.println( "c$\\movies " + f3.canWrite() );
> 
> SmbFile f4 = new SmbFile( "smb://administrator@10.1.1.10/c$/movies/" );
> System.out.println( "c$\\movies " + f4.canWrite() );
> 
> %>
> 
> outputs 
> 
> INFO  [stdout]: c$ false
> INFO  [stdout]: c$ false
> INFO  [stdout]: c$\movies true
> INFO  [stdout]: c$\movies true
> 
> 
> I was expecting to get a true at c$
> 


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


More information about the jcifs mailing list