[jcifs] how to cache NtlmPasswordAuthentication

snowc chsnow123 at gmail.com
Tue Sep 8 12:00:21 MDT 2009


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 );

Many thanks,

Chris


Michael B Allen wrote:
> 
> On Tue, Sep 8, 2009 at 3:17 AM, snowc<chsnow123 at gmail.com> 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/
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-cache-NtlmPasswordAuthentication-tp25340981p25351176.html
Sent from the Samba - jcifs mailing list archive at Nabble.com.



More information about the jCIFS mailing list