Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

Reply
Contributor
BeSeWe
Posts: 17
Registered: ‎06-05-2012
My Device: Bold 9900
My Carrier: T-Mobile Germany

BWS Unauthorized failure with Active directory credentials.

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().compareTo("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

 

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: BWS Unauthorized failure with Active directory credentials.

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.

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
BeSeWe
Posts: 17
Registered: ‎06-05-2012
My Device: Bold 9900
My Carrier: T-Mobile Germany

Re: BWS Unauthorized failure with Active directory credentials.

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#{http://ws.rim.com/enterprise/admin}echo has thrown exception, unwinding now
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;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request requires HTTP authentication ().</u></p><HR size="1" noshade="noshade"><h3>JBossWeb/2.0.0.GA_CP</h3></body></html>

 

EchoRequest requestx = new EchoRequest();
String text = "test";
requestx.setText(text);
EchoResponse response = _myCoreWSStub.echo(requestx);
if (response.getReturnStatus().getCode().compareTo("SUCCESS") != 0) {
  System.out.println("Error occurred: " + response.getReturnStatus().getMessage());
} else {
  System.out.println(response.getText());
}

 Thanks.

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: BWS Unauthorized failure with Active directory credentials.

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"?

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Contributor
BeSeWe
Posts: 17
Registered: ‎06-05-2012
My Device: Bold 9900
My Carrier: T-Mobile Germany

Re: BWS Unauthorized failure with Active directory credentials.

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.

 

 

Please use plain text.
New Contributor
DarkSonicxxx
Posts: 2
Registered: ‎11-29-2012
My Device: BlackBerry Carve 8520
My Carrier: cellc.mobi

Re: BWS Unauthorized failure with Active directory credentials.

 
Please use plain text.
New Contributor
DarkSonicxxx
Posts: 2
Registered: ‎11-29-2012
My Device: BlackBerry Carve 8520
My Carrier: cellc.mobi

Re: BWS Unauthorized failure with Active directory credentials.

Hi I cannot active BES on may Black Berry Carve 8520
Please use plain text.