The crmsvcutil program has some lousy code in it that breaks when you are using "Claims based authentication" (which is used for Internet Facing Deployments - IFD).
This error shows up as:
" Exiting program with exception: The logon attempt failed
Enable tracing and view the trace files for more information."
The fine folks at adxstudio have provided a dll that you can use to work around the problem. http://community.adxstudio.com/Default.aspx?DN=9a7499fb-4e9a-408c-8096-6d658f9509a2
This is specifically for the 5.0.3 version of the SDK, which is the one currently available today at http://www.microsoft.com/downloads/en/details.aspx?FamilyID=420f0f05-c226-4194-b7e1-f23ceaa83b69
Presumably MS will fix this in the next SDK release.
Put the dll into the bin directory that has your crmsvcutil, and then add to your command line:
/metadataproviderservice:"MetadataProvider.IfdMetadataProviderService, MetadataProvider" /codecustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration"
For example, a working command line is:
C:\projects\crm2011\sdk5.0.3\sdk\bin>crmsvcutil /url:https://CRM.YOURCOMPANY.COM/xrmservices/2011/organization.svc /out:xrm.cs /u[username] /p:"[passwordgoeshere]" /metadataproviderservice:"MetadataProvider.IfdMetadataProviderService, MetadataProvider" /codecustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization, Microsoft.Xrm.Client.CodeGeneration"
The root cause is the MS crmsvcutil included this code:
if (orgServiceConfig.AuthenticationType != AuthenticationProviderType.LiveId)
which doesn't account for IFD using AuthenticationProviderType.Federation
(bug found in http://social.microsoft.com/Forums/en/crmdevelopment/thread/10bfc1ca-3cac-46d9-99b5-8f997e4b1ec9?prof=required)