Monday, February 1, 2016

SSRS 2012 – 401 Unauthorized and “Unknown Username or Bad Password”

I’ve been developing software for (unlucky) 13 years now. I’m not doing anything bleeding edge, I’m not pushing boundaries or running beta software on production software, but I do write my fair share of code.

We recently ran into issues with our Production SSRS (SQL Server Reporting Services) instance and found out that our performance has some serious bottlenecks.  We decided it’s probably best to rebuild the server on some better hardware and performance tune SSRS prior to putting it live.

Along the way, I had to get my applications to connect to the server, to feed it report parameters and consume the rendered reports.  Once I started updating my software and tried testing I got an error. Looking at my error logs, the exception was 401 Unauthorized.  Nonsense! It’s the same username and password I’ve been using all along to log into the server!  More, and more, and more, and more digging, and eventually I see in the Windows Even Logs that the Security Audit shows a failed attempt, the error was “Unknown Username or Bad Password”.

Another day and a half we spent on the issue. Was the server setup for Kerberos? Do we need to specify the domain? Do we have to use NTLM? Should we use the IP address to connect rather than the fully qualified domain name?

You surely know where this is going by now.. correct?

Incase you don’t, I eventually retreated to looking at my application’s config file.  There, I specified the username and password, and sure enough I found the fatal flaw:

<add key="SSRS_Username" value="ReportingUser " />

Do you see it?  I stared that this for days!  Tonight, I finally noticed it.. the trailing space at the end of the username.  I updated my config setting to the correct value:

<add key="SSRS_Username" value="ReportingUser" />

Retested, and all worked as expected.

Moral of the story?  No matter how long you’ve been in this business, if the error says “unknown username or bad password”, check the username and the password…

No comments:

Post a Comment