11-30-2012 05:52 AM
Hi,
Im trying to call a webservice which has NTLM type authentication.I heard that Blackberry does support NTLM authentication with the aid of BES. All we need to do is set Authentication=true in MDS-CS of BES and from coding part we just need to do BASIC authentication scheme. Is it true?...if it is true, then why im not able to make the connection.Im sending the credentials along with the Url from my application but im getting 401 response.
The code i have written is
murl=http://myrequiredurl.com/
String mparams=username.gettext()+":"+password.get
byte[] encoded = Base64OutputStream.encode(login.getBytes(), 0,login.length(),false, false);
ConnectionFactory connectionFactory = new ConnectionFactory();
ConnectionDescriptor connDescriptor = (ConnectionDescriptor) connectionFactory.getConnection(mUrl);
if (connDescriptor != null) {
try {
connection = (HttpConnection) connDescriptor.getConnection();
connection.setRequestMethod(HttpConnection.POS
connection.setRequestProperty("Content-Type","
//connection.setRequestProperty("Content-Lengt
connection.setRequestProperty("Authorization", "Basic " + new String(mParams));
responseCode = connection.getResponseCode();
}
catch(Exception e){}
If this is not the way to make a connection for NTLM authenticated webservices, please help me to do so.
11-30-2012 06:48 AM
I don't really understand the various authentication mechanisms, sorry.
But what I do know is that for MDS processing, you can not put the login information into the request until you have been asked for it. In other words, you should not add this header:
connection.setRequestProperty("Authorization", "Basic " + new String(mParams));
until you have actually had a 401.
There is something in the BES processing where it tries to cache something. Mark Sohm explained it once on a Thread here - if you search you might find it.
Anyway, have a look at this KB article which demonstrates one way to retry the connection after you get a 401.
11-30-2012 07:02 AM
12-05-2012 12:38 AM
Yes i have did in the same way which you had told. Even now im getting the response code as 401. My doubt is that, is it the correct way to append username : password for NTLM authentication ? we write this syntax(username : password) for BASIC autnetication scheme. will this method even work for NTLM?..please simon help me in this issue
12-05-2012 01:48 AM
Hi peter,
I have tried doing the same way as it was in the example provided by you. But of no use, Please help me in making an HttpConnection with server authentication model as NTLM. The example you provided was of BASIC authentication.
12-05-2012 02:47 AM
12-05-2012 04:07 AM
Hi simon,peter
without authentication how can i access an protected webservice and for every user the data from the server gets changed .without knowing particular user who has launched application how can i dispaly the content from the server?..if im wrong please explain me in detailed way what exactly is happening when i try to connect an NTLM authenticated webservice.
Lets assume im trying the whole thing from a blackberry deivce,not from simulator.
12-05-2012 04:32 AM