Recently I’ve been working on creating a simple web interface to the Windows Media Services, The problems I’ve run into are various, but one of them sticks out.  Since I am doing something I’ve never done before and the error was new to me it resulted in some time consuming debugging and problem solving.  The error is  :

“Retrieving the COM class factory for component with CLSID {845FB959-4279-11D2-BF23-00805FBE84A6} failed due to the following error: 80070005.

  Thanks to the .net debugging messages I quickly found out that it basicly means that the identity that runs the website doesn’t have permission to access the WMSServer (COM Object with the given CLSID) object, which in return explains why I haven’t run into this (or similiar errors) before since I usually follow the bad programming practice of testing and running my code on an administrative user (Bad Joe, Bad!).  The solution is relatively simple,  run the code with a user with higher system access than the default user (Network Service) but there in lies a problem.  The easy solution would be to run the website with the System identity but that opens up a huge attack vector and should be avoided at all cost. My approach to this was keep running the website under the default identity but programatically impersonate another identity when required, one who has access to the desired COM object.

I didn’t want to use a local system account for this so I created another user that is strictly used for the impersonation and nothing else in addition I created a new user group called DCOMRemoteAccess that will be given access to the required dcom object and every user that requires access to it will be added to this group.  To edit the permissions of the object open up the Component Services window (should be in the Administrative Tools ) and under DCOM Config you should be able to find the DCOM object there.  Take a look at the screenshot for an idea of how this is configured.

When you are done configuring access you may need to reboot the machine for the changes to take effect.

Even though this is written for an error relating to the Windows Media Services dcom object I’m sure this article can be of help in solving other similiar errors.  If you have problem finding the correct dcom object to edit permissions for try searching the registry for the CLSID in the error message.  There should be an entry for it under  HKEY_CLASSES_ROOT\CLSID with an AppID key which should point you to the correct object in the Component Services windows.

One Response to Solving the WMSServer “Retrieving the COM class factory ..” error

  1. Ron says:

    This doesn’t work for me. After doing the registry change, it is still greyed out. Very frustrating because I have been dealing with this for over two weeks. I can’t even create a MUCH NEEDED WMSServer object.