سؤال

I'm trying to get a list of Files of a smb-share secured with user and password. This is working perfectly. But if I try to open a file on the smb-share, windows requires me to login again in an prompt. I have the required username and password. Can I do the login in code before opening the file?

Accessing the files with jcifs:

        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(
                rootFolderPath, user, passwort);
        SmbFile smbServer;
        try {
            smbServer = new SmbFile("smb://" + rootFolderPath, auth);

        } catch (MalformedURLException e) {
            e.printStackTrace();
            continue;
        } catch (SmbException e) {
            e.printStackTrace();
        }
هل كانت مفيدة؟

المحلول

A solution is the usage of a "net use"

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top