|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
how to cache NtlmPasswordAuthenticationI have an web application that accesses images on a samba server. The application always connects to the samba server with the same user name and password. A typical scenario is that the application retrieves 10 to 20 images from the samba server This process repeats, serving up different batches of images to the web app users.
There is a delay of a few seconds retrieving the first image in the batch, presumably for the authentication to take place. The next images in the batch are loaded quickly. I can't see how I can decrease the delay retrieving the first image in the batch. I have tried tweaking the jcifs properties but I'm not getting anywhere (code below). Any pointers would be greatly appreciated! Many thanks in advance, Chris ---- public class SmbUtil { private static NtlmPasswordAuthentication auth; static { String wins = UtilProperties.getPropertyValue("Config.properties", "smb.wins"); String smbdc = UtilProperties.getPropertyValue("Config.properties", "smb.dc"); String domain = UtilProperties.getPropertyValue("Config.properties", "smb.domain"); String userName = UtilProperties.getPropertyValue("Config.properties", "smb.userName"); String password = UtilProperties.getPropertyValue("Config.properties", "smb.password"); try { jcifs.Config.setProperty( "jcifs.netbios.wins", wins ); jcifs.Config.setProperty( "jcifs.netbios.cachePolicy", "-1" ); jcifs.Config.setProperty( "jcifs.smb.client.soTimeout", "100000"); jcifs.Config.setProperty( "jcifs.netbios.soTimeout", "100000"); UniAddress dc = UniAddress.getByName( smbdc ); auth = new NtlmPasswordAuthentication( domain, userName, password ); SmbSession.logon( dc, auth ); } catch (...) { ... } } public static NtlmPasswordAuthentication getSmbAuth() throws Exception { return auth; } } The code for serving the images is: // doGet() - runs once for each image in the batch auth = SmbUtil.getSmbAuth(); SmbFile file = new SmbFile(filename, auth); in = new SmbFileInputStream(file); bytes = IOUtils.toByteArray(in); // return bytes; |
|
|
Re: how to cache NtlmPasswordAuthenticationOn Tue, Sep 8, 2009 at 3:17 AM, snowc<chsnow123@...> wrote:
> > I have an web application that accesses images on a samba server. The > application always connects to the samba server with the same user name and > password. A typical scenario is that the application retrieves 10 to 20 > images from the samba server This process repeats, serving up different > batches of images to the web app users. > > There is a delay of a few seconds retrieving the first image in the batch, Sounds like a name service problem. Try setting jcifs.resolveOrder=DNS and make sure you use a fully qualified DNS hostname in your SMB URL. > presumably for the authentication to take place. The next images in the > batch are loaded quickly. Authentication should take only a few milliseconds unless the Samba server is not configured properly in which case it may be the delay. But if you can connect to it quickly using something other than JCIFS, this is probably not the issue. > I can't see how I can decrease the delay retrieving the first image in the > batch. I have tried tweaking the jcifs properties but I'm not getting > anywhere (code below). > > Any pointers would be greatly appreciated! > > Many thanks in advance, > > Chris > > ---- > > public class SmbUtil { > > private static NtlmPasswordAuthentication auth; > > static { > String wins = UtilProperties.getPropertyValue("Config.properties", > "smb.wins"); > String smbdc = UtilProperties.getPropertyValue("Config.properties", > "smb.dc"); > String domain = UtilProperties.getPropertyValue("Config.properties", > "smb.domain"); > String userName = UtilProperties.getPropertyValue("Config.properties", > "smb.userName"); > String password = UtilProperties.getPropertyValue("Config.properties", > "smb.password"); > > try { > jcifs.Config.setProperty( "jcifs.netbios.wins", wins ); Do you really use WINS? Does anyone really use WINS anymore? If yes, you will need to set jcifs.resolveOrder=WINS and make sure your WINS properties are correct. > jcifs.Config.setProperty( "jcifs.netbios.cachePolicy", "-1" ); > jcifs.Config.setProperty( "jcifs.smb.client.soTimeout", "100000"); > jcifs.Config.setProperty( "jcifs.netbios.soTimeout", "100000"); I would not set any of the above. You'll cause more harm than good I think. Mike -- Michael B Allen Java Active Directory Integration http://www.ioplex.com/ |
|
|
Re: how to cache NtlmPasswordAuthenticationI've commented out the properties (including the wins server). I was passing an IP address for the domain controller and not a dns name, so I don't think the problem is dns. The files are stored on a QNAP NAS server which authenticates with a windows 2003 active directory server. Logging in with smbclient from a remote box takes milliseconds, but the first image loaded through jcifs is taking approx 10 seconds. My authentication code is effectively:
UniAddress dc = UniAddress.getByName( "192.168.0.125" ); auth = new NtlmPasswordAuthentication( "dh.local", userName, password ); SmbSession.logon( dc, auth ); Many thanks, Chris
|
|
|
Re: how to cache NtlmPasswordAuthenticationOn Tue, Sep 8, 2009 at 2:00 PM, snowc<chsnow123@...> wrote:
> > I've commented out the properties (including the wins server). I was passing > an IP address for the domain controller and not a dns name, so I don't think > the problem is dns. The files are stored on a QNAP NAS server which > authenticates with a windows 2003 active directory server. Logging in with > smbclient from a remote box takes milliseconds, but the first image loaded > through jcifs is taking approx 10 seconds. My authentication code is > effectively: > > UniAddress dc = UniAddress.getByName( "192.168.0.125" ); > auth = new NtlmPasswordAuthentication( "dh.local", userName, password ); > SmbSession.logon( dc, auth ); I don't really understand what you're trying to do here. The SmbSession.logon() method just validates some credentials. Also, even though the API documentation does not indicate so, it is deprecated. Just pass that NPA to an SmbFile constructor and get rid of the logon() stuff. That does nothing. Mike\ -- Michael B Allen Java Active Directory Integration http://www.ioplex.com/ |
| Free embeddable forum powered by Nabble | Forum Help |