SmbAuthException

View: New views
2 Messages — Rating Filter:   Alert me  

SmbAuthException

by Srivatsan-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

We are bundling jcifs with our product and one of our customer is facing a strange issue.
We get a "SmbAuthException: Logon failure: unknown user name or bad password" when trying to check for the existence of ADMIN$ share.
The username and password provided are correct.
Im attaching a sample java code, which is exactly the same that we use in our product.

What can be the reasons for logon failure. Should we need to check the values for any security policy ?
We are using a Domain account to login. So the value of "Network Access: Sharing and Security model for local accounts" must not be relevant here, but anyway it is "Classic".

net use \\systemName\admin$ goes through without asking for any password.
Any help in resolving the issue is greatly appreciated.

Thanks,
Srivatsan.


import jcifs.smb.SmbFile;

public class Exists {

    public static void main( String argv[] ) throws Exception {
        if(argv.length < 4)
        {
            System.out.println("Usage : Exists <HostName> <DomainName> <UserName> <Password>");
            System.exit(1);
        }
 
        String smburl = createSMBURL(argv[1],argv[0],argv[2],argv[3],"ADMIN$");
        SmbFile f = new SmbFile( smburl );
        if( f.exists() ) {
            System.out.println("==========================");
            System.out.println("ADMIN$ exists" );
        } else {
            System.out.println("ADMIN$ does not exist" );
        }

        smburl = smburl + "/";
        f = new SmbFile(smburl);
        SmbFile[] files = f.listFiles();
        for( int i = 0; i < files.length; i++ ) {
            System.out.print( " " + files[i].getName() );
        }
        System.out.println();
        System.out.println("==========================");
    }

    public static String createSMBURL(String domain, String host, String user, String pwd, String path) {
        domain = doURLEncoding(domain);
        host = doURLEncoding(host);
        user = doURLEncoding(user);
        pwd = doURLEncoding(pwd);

        return "smb://"+(((domain == null)||(domain.length() == 0))?"":(domain+";"))+
            user+":"+pwd+"@"+host+"/"+path;
    }

    private static String doURLEncoding (String str){
        if (str == null) {
            return str;
        }
        try {
            String conv =  java.net.URLEncoder.encode(str, "UTF-8");
            return conv.replace('+', ' ').replaceAll(" ", "%20");
        } catch (java.io.UnsupportedEncodingException e) {
            e.printStackTrace();
            return str;
        }
    }
}


Re: SmbAuthException

by Michael B Allen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 6/18/08, Srivatsan <srivatsanp@...> wrote:
>
>  Hi all,
>
>  We are bundling jcifs with our product and one of our customer is facing a
> strange issue.
>  We get a "SmbAuthException: Logon failure: unknown user name or bad
> password" when trying to check for the existence of ADMIN$ share.
>  The username and password provided are correct.

Provided the HTTP filter is not somehow involved, I have never known
this error not to mean exactly what it says.

Mike

--
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/
LightInTheBox - Buy quality products at wholesale price