web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM 2011: C# Plugin error - Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

(0) ShareShare
ReportReport
Posted on by

Hi 

I have a C# plugin which reads data from a different SQL server DB (through stored procedure) and creates record in CRM.

Stored Procedure:

The data is retrieved from a table in linked server.

Code:

DataSet dsCandidatesWithInvalidBAPS = new DataSet();

SqlDataAdapter da = new SqlDataAdapter("GetContactDataWithFaults", xyzDB);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.CommandTimeout = sqlTimeout;
da.SelectCommand.Parameters.Add("@topRows", SqlDbType.Int).Value = taskSchedulerArgs[0];

xyzDB.Open();

da.Fill(GetContactDataWithFaults);   ------> error at this line

Error message: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

Could you help me please?

Thanks

Bab

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    from the error looks like you didn't specify a username/password to connect to this SQL server, so the sql connection tries to connect with the default parameters and in this case the user is NT AUTHORITY\ANONYMOUS LOGON that has no rights to your database.

    update your sql connection to include the username and password of a valid user for that db

  • Community Member Profile Picture
    on at

    Hi Guido

    Thanks for your reply. I already have the username and password of the user which is valid for the database.

    My connection string is:

    <add name="xyzDB" connectionString="Data Source=servername;Initial Catalog=xyzdb;User Id=domain\username; Password=pwd;Integrated Security=True" providerName="System.Data.SqlClient"/>

    Thanks

    Bab

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Remove Integrated Security=true piece from your connection string.

  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    probably you put this connection string inside an app.config, but plugins can't access to the app.config

    so you need to put the connection details inside the secure configuration of your plugin and read the string from it, or hardcode the connection details inside the plugin.

  • Community Member Profile Picture
    on at

    Hi

    I would prefer using windows authentication, can you let me know why should I remove the "Integrated Security = true" please?

    Thanks

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Because when you have this option identity of current application is used. If you want to use credentials from your connection string you should remove this piece. You can find additional explanation here - stackoverflow.com/.../difference-between-integrated-security-true-and-integrated-security-sspi

    Good luck.

  • Community Member Profile Picture
    on at

    Hi Andrii

    I am getting an error after removing this line of code as well.

    Regards

    Bab

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Can you please provide code that you use, connection string and error that you get?

  • Community Member Profile Picture
    on at

    Code:

    DataSet dsCandidatesWithInvalidBAPS = new DataSet();

    SqlDataAdapter da = new SqlDataAdapter("GetContactDataWithFaults", xyzDB);
    da.SelectCommand.CommandType = CommandType.StoredProcedure;
    da.SelectCommand.CommandTimeout = sqlTimeout;
    da.SelectCommand.Parameters.Add("@topRows", SqlDbType.Int).Value = taskSchedulerArgs[0];

    xyzDB.Open(); ------> error at this line

    da.Fill(GetContactDataWithFaults);

    Connection string:
    <add name="xyzDB" connectionString="Data Source=servername;Initial Catalog=xyzDB;User Id=domain\username; Password=pwd providerName="System.Data.SqlClient"/>


    Error:
    Login failed for user 'domain\username'.

    Regards
    Bab

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    That means that user "domain\username" doesn't have privileges to access xyzDB database or server "servername" at all.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans