Discussion:
[jcifs] SmbAuthException during makedirs()
Rakesh
2005-01-20 22:18:11 UTC
Permalink
Using jcifs-1.1.7.jar, I get jcifs.smb.SmbAuthException. Same exception
occurs during parent.makedir(), parent.makedir(), and parent.exists(). I
am able successfully create a file on the remote share if the directory
already exist; but I have not been successful in creating a new directory.


jcifs.smb.SmbAuthException: Logon failure: account currently disabled.
at jcifs.smb.SmbTransport.send(SmbTransport.java:695)
at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:289)
at jcifs.smb.SmbSession.send(SmbSession.java:246)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:134)
at jcifs.smb.SmbFile.connect(SmbFile.java:827)
at jcifs.smb.SmbFile.connect0(SmbFile.java:797)
at jcifs.smb.SmbFile.queryPath(SmbFile.java:1202)
at jcifs.smb.SmbFile.exists(SmbFile.java:1285)
at jcifs.smb.SmbFile.mkdirs(SmbFile.java:2250)
at com.conformative.servicenet.services.CIFSResourceComponent.save
(CIFSResourceComponent.java:241)


The following is my java code that I use to create a file:


public boolean save(String relativeFilename, InputStream dataStrm) throws
IOException
{
SmbFile file = new SmbFile(cifsDir, relativeFilename);
if (!file.getCanonicalPath().startsWith(cifsDir.getCanonicalPath()))
return false;

SmbFile parent = new SmbFile( file.getParent() );
if( parent!=null && !parent.getPath().equals( cifsDir.getPath() ) )
parent.mkdirs();

OutputStream outStrm = file.getOutputStream();
Util.copyStream( dataStrm, outStrm );
return true;
}

-Rakesh
Michael B Allen
2005-01-21 02:01:02 UTC
Permalink
Post by Rakesh
Using jcifs-1.1.7.jar, I get jcifs.smb.SmbAuthException. Same exception
occurs during parent.makedir(), parent.makedir(), and parent.exists(). I
am able successfully create a file on the remote share if the directory
already exist; but I have not been successful in creating a new directory.
jcifs.smb.SmbAuthException: Logon failure: account currently disabled.
Well that error is coming from the server so it's legit. Double check your
credentials.

Mike
Rakesh
2005-01-21 14:36:19 UTC
Permalink
Post by Michael B Allen
Well that error is coming from the server so it's legit. Double check your
credentials.
With the same credentials, I am able to successfully use:
smbfile.delete(), file.isDirectory(), smbfile.listFiles() and
smbfile.getOutputStream(). Only the sbmfile.exists(), smbfile.makedir(), and
smbfile.makedirs() are failing with SmbAuthException.

What should I check for to ensure the credentials are correct. UserID &
Password are correct and operational on other smb APIs.
Rakesh
2005-01-21 15:03:31 UTC
Permalink
Post by Michael B Allen
Well that error is coming from the server so it's legit. Double check your
credentials.
Mike
I have found a problem with my usage of credentials as you sugguested. It
seems, that specifing the credentails again when creating a new smbfile
for the directory will work. My usage of file.getParent() assumed a
return object of smbfile which inherited credentials was very wrong.
file.getParent() returns simpile string!

Following fails:

NtlmPasswordAuthentication userCred = new NtlmPasswordAuthentication(domain,
username, password);
SmbFile cifsDir = new SmbFile( netPath, userCred);
SmbFile parent = new SmbFile( file.getParent() )
parent.mkdirs(); // <-- Throws exception


Following will work:

NtlmPasswordAuthentication userCred = new NtlmPasswordAuthentication(domain,
username, password);
SmbFile cifsDir = new SmbFile( netPath, userCred);
SmbFile parent = new SmbFile( file.getParent() ), userCred );
parent.mkdirs(); // now works.


Thanks for the pointer to the credentials.

Loading...