AzureAD: The user or administrator has not consented to use the application with ID ”

I have recently been working on a Multi-tenant Web Application that makes use of delegated permissions.

After developing the application for a while I found that I needed to add another delegated permission to the application which I did using the normal methods.

However, when I tried to make use of the new delegated permission with the test user I had been using for a while I didn’t get prompted for the application’s consent as I did originally and I ran into the error:

The user or administrator has not consented to use the application with ID '<App ID>'

However, when I used a completely new user who hadn’t used the web application before, there were no issues at all. This led me to believe that there was a problem with the new delegated permission not applying to my normal test user, I had expected a new prompt for consent when I went to access the application given that the permissions had changed, however this didn’t happen and therefore led me to believe that the issue was related to this change and me never granting the consent for the additional permissions.

I scoured the internet for any documented help with this but I wasn’t able to find anything, certainly not documented.

I was able to solve the issue in the end by revoking the consent for the test user and re-logging into the application and therefore re-consenting but with the new permissions. This can be done as follows:

  1. Navigate to https://myapps.microsoft.com
  2. Click on the properties for the App and click on remove
  3. Log out of the application or open a new in-private browser session and you will get prompted for consent
  4. Delegated permissions will now work.
Advertisements

Sending E-mail With PowerShell

Been looking for something like this in a while to test newly setup or existing SMTP setups for simple server notification or business applications e.g. SharePoint, as it saves you having to install telnet or putty in order to send a quick test email to make sure its not getting blocked somewhere i.e. spam:

## Update ##
Just found out there’s an actual powershell Cmdlet for this: Send-MailMessage!


$msg = new-object Net.Mail.MailMessage

#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

#Email structure
$msg.From = "fromID@xxxx.com"
$msg.To.Add("toID@xxxx.com")
$msg.subject = "My Subject"
$msg.body = "This is the email Body."

#Sending email
$smtp.Send($msg)

Thanks to SharePoint and Others for the basics!

Unable to use SQL Aliases in IIS Manager or Visual Studio

I Have always had a problem with IIS Manager using SQL Aliases when using the built in .Net membership providers (mainly cause its handy to test and setup the initial FBA user) but never managed to get down to the cause of the issue, just took it as one of those things.

Luckily it was never really that important to resolve so it got left as specifying the alias in the web.config file did appear to work fine. However, a colleague had a similar problem with Visual Studio when trying to regenerate a database layer, which was a bit more of an issue due to the storing of the string.

After a bit of googling we managed to track down the issue:

If like me your happy using the “cliconfg” command to specify aliases (mainly because its included in Windows Server 2008 R2 and there’s no need to install the SQL Native Client manually), its important to understand that the architecture is important, this is where “Native Client” should have given the hint. The problem is that the 32bit client and the 64bit client store their registry keys in different locations, therefore adding an alias in one doesn’t add it to the other. IIS Manager and Visual Studio are both 32bit applications and therefore use the 32bit aliases, however running the “cliconfg” command from run or a command prompt on a 64bit machine unsurprisingly loads the 64bit version of the client configuration tool. Therefore, if you run into this issue, you should run “c:WindowsSysWOW64cliconfg.exe” for the 32bit version.

Note: I have no idea why 32bit applications are stored in SysWOW64 and the 64bit ones in System32… appears like it should be the other way around to me?!

Visual Studio Themes

Stumbled upon a great site today for anyone who prefer’s a slightly different editor theme in visual studio. Studio Styles is a website containing loads of colour themes for both VS 2008 and VS 2010 and also includes a ratings system. Even if your happy with the default colours I would recommend checking the site out just in case anything catches your eye. I prefer the low contracts themes these days as its just easier on the eye!

Google Wave Scrapped

If anyone has seen any of the details for Google wave, or perhaps were invited to the Beta, Googles cancellation of the project may not come as such a surprise. In a nutshell, Google wave was described as an e-mail/instant messaging system with a touch of collaboration. In fact most of the content for Google wave compared it alot with e-mail however, this is primarily where I believe problem lay.

Google wave improved on the E-mail de-facto that we still use today and had the potential to become email 2.0, except that you couldn’t e-mail (or add to your “Wave”) anyone who wasn’t on Google Wave. Don’t get me wrong, some of the features were really cool and the interface and base idea were great, but allowing wave to be compatible with standard e-mail systems I believe would have made it a hit. I’m not by any means suggesting that this would have been easy and I may be missing the whole point of what Wave was all about, but backwards compatibility with e-mail really would have helped Wave’s cause.

Who knows, I may get bored one rainy day and give it a try!

P.s. Please don’t make the same mistake with your social networking Google, your simply not going to get people to leave Facebook, so your better off integrating with it but adding Google goodness!

The death of Windows Mobile?

Today when upgrading a products codebase from Visual Studio 2008 to Visual Studio 2010 I discovered that Microsoft have removed support for smart device projects in Visual Studio 2010. The decision to exclude support for smart device projects in Visual Studio 2010 appears to be a clear sign that Microsoft does not intend on continuing the Windows Mobile roadmap independently of Windows Phone 7. Windows Phone 7 is clearly targeted at the consumer space to complete with the likes of Apple iPhone and Google Android. The business application of Windows Phone 7 is going to be unproven and therefore it was thought that Microsoft would continue the existing 6/6.5 roadmap to support the likes of enterprise solutions on rugged devices. However, the exclusion appears to suggest that Microsoft has indeed ditched the Windows Mobile platform at least in its current format.

Details regarding Visual Studio 2010’s support can be found here You can obviously still continue with development of Windows Mobile on Visual Studio 2008 but I don’t really want to have Visual Studio 2008 installed alongside Visual Studio 2010. Unfortunately for Microsoft I think many existing Windows Mobile ISV’s like ourselves will now be considering switching to a rival format such as Google Android if the cost of migration is simply too high for Windows Phone 7. With that said, the platform chosen by rugged device manufacturers will also have a huge impact on the outcome.

SQL Express: Viable database for Application Development?

Microsoft SQL Express offers so much when evaluating a persistence store for your own applications, especially if you are targeting Windows and utilising the .Net framework.

SQL Express offers pretty much most of the common features available in the full blown SQL Server which makes development and switching between SQL Server and SQL Express pretty seamless. However, there is one major factor which I would reccomend you consider… Deployment. You would expect the deployment of SQL Express to be as easy as installing say the .Net framework, which you will no doubt have to distribute.

In fact if you are targeting an internal business project or something with a fairly small consistant machine image (e.g. same operating system version) then you may not have too many problems, hey you can even set it as a pre-requisite to install along with the .Net framework as part of your visual studio deployment project.