Category Archives: Configuration

Exchange Web Service (EWS) configuration

Exchange Web Service (EWS) configuration

The idea here is to create two groups within the Active Directory. The first group will contain the Mailbox accounts you wish to allow access and manipulation of objects within the mailbox (sgEWSImpersonatable). The second will contain the accounts you wish to allow access to the accounts within the first group (sgEWSImpersonate).

What we want to do is

  • AD – Create a security group (sgEWSImpersonateAble), this group will hold the accounts we want to be able to impersonate (eg testAccounts, devsystems etc etc)
  • AD – Create a security group (sgEWSImpersonate), this group will hold the accounts we want to allow impersonation of the accounts in the group sgEWSImpersonateAble
  • EX – Create a Scope (scopeEWSImpersonate), this scope we use to link the ApplicationImpersonation Exchange role to the security group created in the previous step. . Ie we assign the scope to the security group sgEWSImpersonateAble
  • EX – Create a RoleAssignment (mraEWSImpersonation) this Management Role Assignment will be used to tie the ApplicationImpersonation role to the scope. this then compeltes the loop between AD and Exchange

Follow these steps

  1. Create the Security Group in AD (it can be mail enable or not, it makes no difference)
    Group Name: sgEWSImpersonateAble
    Group Description: Exchange Web Service Impersonation, accounts in this group will grant members of the group sgEWSImpersonate impersonation ability via Exchange Web Service calls
    Group Members: TestAccounts, testsqlmailuser, etc,etc,etc
  2. Create the Security Group in AD (it can be mail enable or not, it makes no difference)
    Group Name: sgEWSImpersonate
    Group Description: Exchange Web Service Impersonation, accounts in this group be able to impersonate members of the group sgEWSImpersonateAble via Exchange Web Service (EWS) calls
    Group Members: Developer1,Developer2, Sysadmin1, svcAccount, etc,etc
  3. Create the Scope (This is a one time only requirement to run) In Exchange Management Powershell console run the following, this will link the scope to the groupGet the location of the security group we created for the accounts to impersonate

    >$sgEWSImpersonateAble = $(Get-DistributionGroup sgEWSImperonateAble).Identity.DistinguishedName

    verify we have it by looking at the vaariable
    >$sgEWSImpersonateAble
    CN=sgEWSImpersonateAble,OU=OrganisationalUnitContainingTheGroup,DC=DomainName,DC=local

    Now Create the Scope linking it to the group
    >New-ManagementScope -Name:scopeEWSImpersonate -RecipientRestrictionFilter:”MemberOfGroup -eq ‘$sgEWSImpersonateAble'”

  4. Create the Role Assignment (to link the scope to the group containing the accounts we want to allow impersonation to)>New-ManagementRoleAssignment –Name:mraEWSImpersonation –Role:ApplicationImpersonation –SecurityGroup “sgEWSImpersonate” –CustomRecipientWriteScope: scopeEWSImpersonate

For a long story short execute the following in the Exchange Management Powershell console. Replace the names to those you would prefer.

>$sgEWSImpersonateAble = $(Get-DistributionGroup sgEWSImperonateAble).Identity.DistinguishedName
>$sgEWSImpersonateAble
CN=sgEWSImpersonateAble,OU=OrganisationUnitContainingTheGroup,DC=Domain,DC=local
>New-ManagementScope -Name:scopeEWSImpersonate -RecipientRestrictionFilter:”MemberOfGroup -eq ‘$sgEWSImpersonateAble'”
>New-ManagementRoleAssignment –Name:mraEWSImpersonation –Role:ApplicationImpersonation –SecurityGroup “sgEWSImpersonate” –CustomRecipientWriteScope: scopeEWSImpersonate

Now you can add and remove people and mailboxes to and from the two groups to allow impersonation of mailboxes from accounts

References

http://msdn.microsoft.com/en-us/library/exchange/bb204095(v=exchg.140).aspx

Set-ManagementRoleAssignment
http://technet.microsoft.com/en-us/library/dd335173(v=exchg.141).aspx
New-ManagementRoleAssignment
http://technet.microsoft.com/en-us/library/dd335193(v=exchg.141).aspx
New-ManagementScope
http://technet.microsoft.com/en-us/library/dd335137(v=exchg.141).aspx
Set-ManagementScope
http://technet.microsoft.com/en-us/library/dd297996.aspx

SQL 2008 SSRS Web Service access from .NET

When you try to access a report server web service to execute code you get an error similar to, where the scheme or header varies a tiny bit

The HTTP request is unauthorized with client authentication scheme ‘Basic’. The authentication header received from the server was ‘Negotiate,NTLM

Basically my situation is that we have a MS 2008 Server running SSRS outside of our domain in the DMZ. However we need to execute code on a domain machine that will connect and run over 100 reports on the SSRS Server, then dump them on a share in our domain in excel format.

To get around the negotiation problem you need to make sure the SSRS server is allowing connections configured using basic authentication

Find the file

rsreportserver.config

This is usually buried in the install folder

C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer

Then change the authentication to support your desired connection authentication type

More info at MSDN
Once you have done that you should be good to connect.
Here is some sample code to get you started with connecting to your web service and pulling back a list of items

ASP.NET Combine & Minify CSS & JSS on the fly (Also tested in Umbraco) in 5 easy steps

Automatically Combine, minify, compress and much more on the fly.
Here you will learn in 5 steps how to implement the combine and minify project originally from codeplex into any .net application. I’ve just tested this on an Umbraco installation and it works flawlessly, the project also makes use of 2 open source libraries.

The original project can be found http://combineandminify.codeplex.com/ I have converted this project from c# to vb and made some considerable further optimisations in the code around the caching mechanism.

The two other libraries included are:

EcmaScript.NET.modified.dll
Yahoo.Yui.Compressor.dll

Along with a lot of custom code to automatically provide a cached based minify & compress  for your css & jss files. But it doesn’t stop there you can also use this project to remove white space from the html rendering to the client (default operation), all comments and commented code in .js and .css file includes is striped , you can insert VersionId’s in font urls and images and even preload images.

Ok so lets break it down.

What does it do and how?

Taking the .js and .css includes in particular, during the request life-cycle of the .net engine combineAndMinify will scan the header of the page just prior to rendering to the client, it will collect up the .js and .css includes, minify, compress, remove comments and white spaces and place the new combined content into the cache. So that’s one cache record for the .js and one for the .css. It will then strip out all the include references from the page header and replace them with a unique include reference pointing to the cached version for the browser to process. in your webconfig you have told IIS that all requests to .js and .css files must be routed through the combineandminify class, so when the browser then requests the include eg 33212cce52b6065a.js, the combineAndMinify handler then pulls the content from the cache and sends it to the client.

This process optimises your site in two ways, it caches the includes, and provides the client with only one include per type to request from the server.

The unique names are calculated using logic on various aspects, for example if you wished that the caching occur per page or for the entire website at domain level.

Out of the box the combineAndMinify is intelligent enough not to touch any include that references a different domain, and is in fact very customisable in that respect.

Furthermore it also knows when any of the files that it has cached change and will automatically update the cached version on the active request the change has been detected on.

See the full spec on codeplex.

Configuration settings:

configuration>combineAndMinify
Config Attribute Default Value Possbile Values
removeWhitespace false true/false
insertVersionIdInFontUrls false true/false
insertVersionIdInImageUrls false true/false
makeImageUrlsLowercase false true/false
prioritizedImages true true/false
preloadAllImages false true/false
cookielessDomains
enableCookielessDomains Always Never
Always/ReleaseModeOnly/DebugModeOnly
minifyJavaScript true true/false
minifyCSS true true/false
combineJavaScriptFiles PerGroup None/PerGroup/All
combineCSSFiles PerGroup None/PerGroup/All
headCaching None None/PerSite/PerFolder/PerPage/PerUrl
exceptionOnMissingFile Never Never/Always/ReleaseModeOnly/DebugModeOnly
active ReleaseModeOnly Never/Always/ReleaseModeOnly/DebugModeOnly

If your even half technical you can guess what half of these configuration settings do, if you need a further understanding on all the configuration settings please visit the codeplex project website because its beyond the scope of this how to.

Implementation

  1. Copy the binaries to your bin folder and add references to them or include the project into your solution
  2. Copy and rename “HeadAdapter.browser.txt” to HeadAdapter.browser to your App_Browsers folder
  3. make the required changes to your web.config file
  4. change the combineAndMinify config attribute “active” from “Never” to “Always”
  5. test the solution in firefox, ie or chrome and verify the compression in firebug F12 Developer tools or FireBug Lite respectively.

The vb.net converted, enhanced version of the project compiled to binaries and other  files you will need:

CombineAndMinify_Dlls

HeadAdapter.browser.txt

web.config.txt

If anyone has any problems at all, I will help where I can. If you want the vb.net version of this project then let me know and I’ll send it over.

Exchange 2010 and exchange 2003 there is currently no route to the mailbox database

As an Administrator, If during your Exchange 2010 install, when you migrated that single test mailbox from the old Exchange 2003 server into the nice shiny new Exchange 2010 mail server on that new MS Server 2008 64bit you have up and running. You found you couldn’t send mail internally or receive mail internally or in fact receive mail from an external source either, your not alone.

Reviewing the “Queue Viewer” on your Exchange 2010 bi you see there are mails in the queue trying to send with the following error

there is currently no route to the mailbox database

And you also see mails in the inbound queue on your exchange 2003 box.

Fear not, for there is a simple fix. You must Create A Routing Group Connector Between Exchange 2003 and Exchange 2010

According to Microsoft when you installed the new Exchange server 2010 despite the compatibility that exchange 2003 and exchange 2010 can coexist on your domain, they don’t quite let you know that the routing may not properly be configured, my guess is because there are too many permutations of network configurations you might have. So if your like me, you have a single Exchange 2003 server that you want to talk to your Exchange 2010 server then the solution is pretty simple.

Make sure you login to the exchange 2010 box with an account that has “GOD” privileges on your domain
1. Click start
2. in the search box type “Shell”
3. Right click and run “Exchange Management Shell”
4. Copy and paste the following line into notepad

New-RoutingGroupConnector -Name “Interop RGC” -SourceTransportServers “exchange2010FQDN” -TargetTransportServers “Exchange2003FQDN” -Cost 10 -Bidirectional $true -PublicFolderReferralsEnabled $true

Adjust the names accordingly and be sure the quotes are quotes and not some funky character that looks like quotes as is what sometimes happens when copying from the internet.
5. Paste the line into the Exchange Management Shell (EMS) and you should see something not too different from this.

response from adding route, and verifying route exists

6. Now you can verify the creation by running “Get-RoutingGroupConnector”
7. On your exchange 2003 box restart “Simple Mail Transport Protocol” Service
8. On your Exchange 2010 box restart “Mail Exchange Transport” Service

Hope this helped you all

References I used
Message Rerouting and the Unreachable Queue
http://technet.microsoft.com/en-us/library/bb232161.aspx

Routing group connector between an Exchange 2010 organization and Exchange 2003 organization doesn’t exist
A routing group connector between the Exchange 2010 routing group and Exchange 2003 routing groups hasn’t been configured, or the last routing group connector between the Exchange 2010 routing group and Exchange 2003 routing groups has been removed. No routing group connector exists to provide a routing path to the Exchange 2003 recipients. To resolve this problem, first verify that the routing group connector is missing. If that’s the case, you can create a routing group connector. For more information, see Create Additional Routing Group Connectors from Exchange 2010 to Exchange 2003. If a routing group connector does exist, the message is in the Unreachable queue for some other reason. Check the configuration of the routing group connector

Create Additional Routing Group Connectors from Exchange 2010 to Exchange 2003
http://technet.microsoft.com/en-us/library/aa997292.aspx

New-RoutingGroupConnector -Name “Interop RGC” -SourceTransportServers “Ex2010Hub1.contoso.com” -TargetTransportServers “Ex2003BH1.contoso.com” -Cost 10 -Bidirectional $true -PublicFolderReferralsEnabled $true

Upgrade from Exchange 2003 Transport
http://technet.microsoft.com/en-us/library/dd638103.aspx
Exchange Management Shell in Exchange 2010
http://technet.microsoft.com/en-us/library/dd795097.aspx

user control is ambiguous in the namespace ‘ASP’

This one was a particular pain.

Long story short try this in your web config

Set batch=”false” under compilation

This will allow you to drill further into the problem, its not a particularly desirable attribute to set in production.

Visual Studio VS 2010 not stopping at breakpoints

Ever wondered why suddenly you cannot debug because the compiler isnt breaking on your breakpoints.

There are several reasons for this.

make sure that.
1. Your project is compiling when you begin debugging (check this in build > configuration manager)
2. Ensure your projects are compiling in debug mode not release (check this in build >configuration manager)
3. In the Webconfig ensure you are in debug mode

4. The (project properties > startup options > debuggers has the ASP.NET checkbox checked)
5. Delete all pdb files in your bin folder
6. Ensure every project referenced is set to build under (build > configuration manager)
7. Do a full clean and rebuild. (build > clean solution) (build > rebuild solution)

Finally and this is the one that caught me out
8. Check you are not setting a cookie cache timeout of positive time, I was expiring my page after 1 day. The best way to check this is to load a page in debug, knowing your break point will not be stopped at. Once the page is fully loaded hit ctrl F5 to force full reload of the page. If your breakpoint is stopped at then you know its a cache problem.

Error 1310 Config.msi verify access

If you recieve the following error when trying to install or uninstall windows applications

Error 1310. Error writing to file: C:\Config.Msi\*******.rbf. System error 5. Verify that you have access to that directory.

You can try and resolve this by re registering windows installer

Open a command prompt Start > run > “cmd”

msiexec /unreg
msiexec /regserver

If this doesnt solve your problem try running your installer from the root of the C drive as an administrator in various compatibility modes.

How To Restore All Your HTC Widgets

Recently my htc widgets have not been available for my home screen (friend stream, mail music, twitter etc) Im not sure what caused it but none the less its happened.

To get them back is pretty simple.

Note: this will completely reset your home screen layouts and wipe any saved layouts
1. Make sure you have over 15mb free space2. Open Settings
3. Select Applications
4. Select Manage Applications5. Scroll to HTC Sense and select it
6. Hit Clear data
7. Press the home button and wait
8. You will now see your widgets available when trying to add via one of the home screens

MS Outlook Error when opening

If you recieve this error when you try to open your Microsoft Outloo client

cannot start microsoft outlook cannot open the outlook window

open a run command “Start > Run” and type this

outlook.exe /resetnavpane

Should fix most errors
Failing that try these references for outlook switches

http://www.petri.co.il/outlook_2003_command_line_switches.htm
http://www.techgalaxy.net/Docs/Exchange/OL2003_switches.htm
http://office.microsoft.com/en-us/outlook-help/command-line-switches-for-microsoft-office-outlook-2007-HP001218589.aspx

Execute denied for sp_send_dbmail

My backup email error handler noted a few errors in the windows event viewer, the specific error was

The EXECUTE permission was denied on the object ‘sp_send_dbmail’, database ‘msdb’, schema ‘dbo’.

If you have receieved this, then you need to add the user to the database by going to properties of the user and editing the “mapping” ensuring that said user is ticked next to the db “msdb”
Then run the follwing trasact against he msdb daabase replacing the word user here with the user you need to apply this to.