06-05-2012 05:45 AM
Hi
I am having problem to access Blackberry Administration Services using BWS API with Active directory credentials. The request failed with HTTP status 401: Unauthorized.
However, it is working FINE with BAS credentials.
I'm using Java and Windows Server 2008.
Here is my code:
GetEncodedUsernameRequest request = new GetEncodedUsernameRequest();
request.setMetadata(_meta);
request.setUsername(username);
request.setOrgUid(_meta.getOrganizationUid());
CredentialType credentialType = new CredentialType();
credentialType.setPASSWORD(true);
credentialType.setValue(password);
request.setCredentialType(credentialType);
request.setAuthenticator(getAuthenticators("Active Directory"));
request.setDomain(domain);
// The BAS expects the username to be encoded, this call returns the encoded value
GetEncodedUsernameResponse geurResponse = _myUtilWSStub.getEncodedUsername(request);
if (geurResponse.getReturnStatus().getCode().compareT o("SUCCESS") != 0) {
System.out.println("Error occurred: " + geurResponse.getReturnStatus().getMessage());
return false;
} else {
System.out.println("Encoded username: " + geurResponse.getEncodedUsername());
// Output = "12,10,1,3,1,0;Aministratordomain-dev11110"
}
String myEncodeUsername = geurResponse.getEncodedUsername();
Thanks in advnace.
Benjamin
06-05-2012 08:35 AM
Hi Benjamin, welcome to the forums!
Has this AD user been added to the BAS as a user account? Can you log in to the BAS console using this AD credentials?
What call are you making that results in the 401? Could you try a call to BWS#echo()? The Echo call will basically let you know if the user authenticated successfully without worrying about permissions that may be required for other calls.
06-05-2012 08:52 AM
Hi Garett,
first thanks for the fast replay.
The User is added to the BAS as an AD account, and I can login over the BAS console.
But if I use the BWS API I get the following error on at the bold marked line of my code.
WARNUNG: Interceptor for {http://ws.rim.com/enterprise/admin}BWSService#{htt
org.apache.cxf.interceptor.Fault: Response was of unexpected text/html ContentType. Incoming portion of HTML stream: <html><head><title>JBossWeb/2.0.0.GA_CP - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;b
EchoRequest requestx = new EchoRequest();
String text = "test";
requestx.setText(text);
EchoResponse response = _myCoreWSStub.echo(requestx);
if (response.getReturnStatus().getCode().compareTo("S UCCESS") != 0) {
System.out.println("Error occurred: " + response.getReturnStatus().getMessage());
} else {
System.out.println(response.getText());
}Thanks.
06-05-2012 10:44 AM
When you log in with this account on the BAS, what do you enter in the "Domain" field? Do you use the same domain in the API call?
If you open this user account on the BAS, what is listed under "Authentication Type"?
06-05-2012 11:15 AM
Hi Garett,
yes the have entered the the domain on the BAS console and on the API call.
I have now removed the user from the BAS and have create it again with the same credential and now it works.
So Thank you very much for your help.
11-29-2012 01:53 PM
11-29-2012 01:55 PM