Tuesday, November 27, 2007

STSADM -- Access Denied

While attempting to deploy some SharePoint code via MSBuild, I ran in to the following problem.

I have a msbuild.proj that executes several stsadm commands. These work perfectly when executed from the command-line. However, once they are called from TeamBuild, I get "Access Denied" on the stsadm execution.

The TFS Service account is a member of the Administrators group on the build server. I can login to the build server as the TFS Service account and execute the command-line successfully. This problem only exists when the commands are spawned from TeamBuild.

I have also tried running several EXEC tasks using runas /trustlevel:unrestricted and various other options with no success.

After several, and far too many, hours attempting to resolve the problem myself, I burned a PSS with Microsoft to resolve this issue.

Here is what I had to do. Even though the TFS Service Account was a member of the Administrators group on the Build Server, I continually received Access Denied errors. The suspicion was that the TFS Service Account, when run from TeamBuild, was not executing as an interactive/desktop user. Therefore, there wasn't a profile that was being used. While I don't claim to fully understand why I was getting the errors, we did reach a solution.

I opened regedit and gave full control to the TFS Service Account for the following keys and their sub-keys. I would imagine Read Only access would work, but I have not explored further. Please let me know if you find anything else that may work.

  • HKLM\Software\Microsoft\SystemCertificates\
  • HKLM\Software\Microsoft\EnterpriseCertificates\
  • HKLM\Software\Microsoft\WBEM\

Wednesday, November 14, 2007

Stupid, Stupid, Stupid... Me!

I hate to admit that I have been plagued by this stupid BizTalk error for weeks now.  I must say that I haven't been focusing on this particular issue the entire time, but when I did it wasn't pretty.  I was never able to wrap my head around the problem, and even worse, the solution.  Until...

The error:
MyOrchestration.odx(783,59): error CS1026: ) expected
MyOrchestration.odx(782,10): error CS1518: Expected class, delegate, enum, interface, or struct

I would receive this error only when a particular orchestration was included in my project.  However, the orchestration that reports the error is not the one causing the error, but the first active orchestration in my directory.  If I set the build action of the offending orchestration to none, the error would go away.  I can say this with 100% certainty that this was the root of my problem as I tried all combinations of which orchestrations were included and found only one causing me grief.

Being the friendly error message that it was, I opened the orchestration using the Xml Editor and took a look under the hood.  The line being referenced was the last line of the file.  In other words, there was no code where the error was supposed to be.  In the past, I had run in to cases where the generated C# code was corrupt, so I deleted all of that section and started over.  Still, I got the same error.  I even tried deleting that orchestration and starting from scratch.  I finally was able to narrow it down to an error somewhere in my mapping and schema files.  Further analysis showed me that the schema reference section was including some very strange data.  Essentially, my source schema looked something like this:

<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://schemas.companyname.com/projectname/FileType_FF&quot; targetNamespace=&quot;http://schemas.companyname.com/projectname/FileType_FF" targetNamespace="http://schemas.companyname.com/projectname/FileType_FF&quot; targetNamespace=&quot;http://schemas.companyname.com/projectname/FileType_FF" xmlns:xs="http://www.w3.org/2001/XMLSchema">

Since this schema was created using the Flat File Wizard, I'm not entirely certain how in the world this happened, but it sure did throw me for a loop.  Especially because the error message had nothing to do with the actual error.  Googling for the error message didn't return any helpful results.  If you are one of the unlucky souls to receive this error, hopefully this will give you some assistance.