Saturday, March 31, 2012

MDSModelDeploy.exe Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.


I was trying to automate the creation and deployment of my MDS model and came across the following issue.

If you try to run the following powershell command

invoke-command -computername Servername -scriptblock {& 'C:\Program Files\Microsoft SQL Server\110\Master Data Services\Configuration\MDSModelDeploy.exe' createpackage -model TestModel  -package c:\Data\LocalBackup\TestModelackage.pkg -version VERSION_1 -service MDS2 -includedata}

you get the following error
Creating a package for model MTN
MDSModelDeploy operation failed. Elapsed time: 00:00:06.4551044
Error:
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

I enabled trace on MDSModelDeploy

Error Log
MDS Information: 0 : Attempting to execute command: MDSModelDeploy createpackage -model TestModel -package c:\Data\LocalBackup\TestModelackage.pkg -version VERSION_1 -service MDS2 -includedata
    DateTime=2012-03-31T10:35:02.3896659Z
MDS Error: 0 : Service started successfully,  Assembly version: 11.0.0.0, file version: 11.0.2100.60 ((SQL11_RTM).120210-1917 )
    DateTime=2012-03-31T10:35:10.6863285Z
MDS Error: 0 : ApiContractVersion: 5102
    DateTime=2012-03-31T10:35:10.6863285Z
MDS Start: 1 : Service.InitializeExpirationStatus
    DateTime=2012-03-31T10:35:10.6863285Z
MDS Information: 0 : Evaluation period days remaining code: 0
    DateTime=2012-03-31T10:35:10.7488269Z
MDS Stop: 2 : Service.InitializeExpirationStatus
    DateTime=2012-03-31T10:35:10.7488269Z
MDS Start: 1 : Deployment: getting list of models
    DateTime=2012-03-31T10:35:10.7644515Z
MDS Start: 1 :
                  Begin operation: ExecuteRequest
                  Host info:       Microsoft.MasterDataServices.Core.ExplicitHostContext
                  User Name:       Domain\username
                  Time:            03/31/2012 21:35:10
    DateTime=2012-03-31T10:35:10.9050729Z
MDS Verbose: 0 : Request message:
<MetadataGetRequest xmlns="http://schemas.datacontract.org/2004/07/Microsoft.MasterDataServices.Services.MessageContracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <International i:nil="true" xmlns:a="http://www.w3.org/2005/09/ws-i18n" />
  <ResultOptions xmlns:a="http://schemas.microsoft.com/sqlserver/masterdataservices/2009/09">
    <a:Models>Identifiers</a:Models>
  </ResultOptions>
  <SearchCriteria xmlns:a="http://schemas.microsoft.com/sqlserver/masterdataservices/2009/09">
    <a:AttributeGroups />
    <a:Attributes />
    <a:DerivedHierarchies />
    <a:DerivedHierarchyLevels />
    <a:Entities />
    <a:ExplicitHierarchies />
    <a:MemberTypes />
    <a:Models />
    <a:VersionFlags />
    <a:Versions />
  </SearchCriteria>
</MetadataGetRequest>
    DateTime=2012-03-31T10:35:11.0613189Z
MDS Start: 1 : RequestContext.InitializeRequestContext
    DateTime=2012-03-31T10:35:11.0613189Z
MDS Start: 1 : RequestContext.InitializeDatabaseContext
    DateTime=2012-03-31T10:35:11.0613189Z
MDS Stop: 2 :
                  End  operation: MetadataGet
                  Host info:       Microsoft.MasterDataServices.Core.ExplicitHostContext
                  User Name:       [Domain]\[Username]
                  Time:            03/31/2012 21:35:11
    DateTime=2012-03-31T10:35:11.2956879Z
MDS Verbose: 0 : Response message:
<MetadataGetResponse xmlns="http://schemas.datacontract.org/2004/07/Microsoft.MasterDataServices.Services.MessageContracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <OperationResult xmlns:a="http://schemas.microsoft.com/sqlserver/masterdataservices/2009/09">
    <a:Errors />
    <a:RequestId>d8cedd0f-34cd-4b43-b43b-e0fd860bb44d</a:RequestId>
  </OperationResult>
  <Metadata xmlns:a="http://schemas.microsoft.com/sqlserver/masterdataservices/2009/09">
    <a:AttributeGroups />
    <a:Attributes />
    <a:DerivedHierarchies />
    <a:DerivedHierarchyLevels />
    <a:Entities />
    <a:ExplicitHierarchies />
    <a:MemberTypes />
    <a:Models />
    <a:VersionFlags />
    <a:Versions />
  </Metadata>
</MetadataGetResponse>
    DateTime=2012-03-31T10:35:11.4206847Z
MDS Error: 0 :
    DateTime=2012-03-31T10:35:11.4206847Z
MDS Error: 0 : MDSModelDeploy operation failed. Elapsed time: 00:00:09.1523012
    DateTime=2012-03-31T10:35:11.4206847Z
MDS Error: 0 : Error:
    DateTime=2012-03-31T10:35:11.4206847Z
MDS Error: 0 : System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
   at Microsoft.MasterDataServices.Core.DataAccess.DbHelper.ExecuteNonQueryHandlingTransportError(SqlCommand sqlCommand)
   at Microsoft.MasterDataServices.Core.DataAccess.DbHelper.GetTimeout(String settingName)
   at Microsoft.MasterDataServices.Core.DataAccess.DbHelper.SetConnection(String connectionString)
   at Microsoft.MasterDataServices.Core.BusinessEntities.RequestContext.InitializeDatabaseContext()
   at Microsoft.MasterDataServices.Core.BusinessEntities.RequestContext.InitializeRequestContext(HostContext hostContext)
   at Microsoft.MasterDataServices.Services.Service.MetadataGet(MetadataGetRequest request)
   at Microsoft.MasterDataServices.WebUI.ServiceAdapter.ExecuteRequest[TRequestType,TResponseType](MdmServiceOperation`2 operation, TRequestType request)
   at Microsoft.MasterDataServices.WebUI.ServiceAdapter.DoMetadataGet(MetadataSearchCriteria searchCriteria, MetadataResultOptions resultOptions)
   at Microsoft.MasterDataServices.Deployment.ModelReader.GetModels(Boolean isAdminOnly)
   at Microsoft.MasterDataServices.Deployment.Utility.ModelDeploy.CreatePackage(String serviceName, String packageFile, String modelName, String versionName, Boolean includeData)
   at Microsoft.MasterDataServices.Deployment.Utility.ModelDeploy.Main(String[] args)
    DateTime=2012-03-31T10:35:11.4206847Z


After using reflector I managed to find the code that is causing the issue
private void InitializeRequestContext(HostContext hostContext)
{
    Log.WriteStart("RequestContext.InitializeRequestContext");
    if (hostContext == null)
    {
        throw new ArgumentNullException("hostContext");
    }
    this.HostContext = hostContext;
    this.InitializeDatabaseContext();
    this.InitializeCurrentUser();
    Log.WriteStop("RequestContext.InitializeRequestContext");
}
Not sure if calling InitializeCurrentUser before InitializeDatabaseContext will fix the problem. As I didn’t have to time to decompile all the MDS code and try to get it to compile.

Work around
Is to set the connection string to sql login instead of Integrated Security
from        <add name="MDS2" connectionString="Data Source=servername;Initial Catalog=database;Integrated Security=True;Connect Timeout=60" />
to            <add name="MDS2" connectionString="Data Source=servername;Initial Catalog=database;User Id=sqlloginuser;Password=password;Connect Timeout=60" />


To test that winrm is working correctly run the following command
invoke-command -computername yourserver -scriptblock {& 'C:\Program Files\Microsoft SQL Server\110\Master Data Services\Configuration\MDSModelDeploy.exe' listservices}
Result
MDS services (Service, Website, Virtual Path):
MDS1, Website1_DEV,
MDS2, Website2_DEV,

MDSModelDeploy operation completed successfully. Elapsed time: 00:00:06.7047133

3 comments:



  1. It is useful to learn how to set and reset a error.Thank you author for posting this kind of error.

    http://www.wikitechy.com/fix-error/login-failed-for-user


    Both are really good.
    Cheers,
    Venkat

    ReplyDelete
  2. Great and that i have a tremendous offer: How Much House Renovation Cost Philippines house renovation near me

    ReplyDelete
  3. Thank You and that i have a tremendous offer: Does Renovation Increase House Value house interior renovation

    ReplyDelete