[jcifs] SmbFile.listFiles with encoded Password
Michael B Allen
mba2000 at ioplex.com
Wed Oct 20 06:36:56 GMT 2004
On Wed, 20 Oct 2004 00:04:04 +0000 (UTC)
Doug Ward <doug_ward at comcast.net> wrote:
> When I create a SmbFile with regular text username and password, the call
> SmbFile.listFiles() works fine, but when I have a password with encoded
> characters I get the SmbException "Network
> Error: //username:password at server/share
>
> My code looks something like this
>
> {
> SmbFile[] subDirs = null;
> String uName = "user";
> String password = "pass%word";
> String path = "server/share/";
>
>
> SmbFile f = new SmbFile("smb://" + URLEncoder.encode(uname) + ":" +
> URLEncoder.encode(password) + "@" + path);
>
> subDirs = f.listFiles(); // Exception thrown here
You have to do:
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication( dom,
uname, password );
SmbFile f = new SmbFile( url, auth );
f.listFiles();
Actually you should do that regardless. Using credentials in the URL is
a big no-no.
Mike
--
Greedo shoots first? Not in my Star Wars.
More information about the jcifs
mailing list