I am hosting a WCF Service in my IIS, and I Encountered the error shown below:
Request Error
The server encountered an error processing the request. Please see the
service help page for constructing valid requests to the service. The
exception message is 'Login failed for user 'IIS APPPOOL\TEST'.'. See
server logs for more details
I call my method with this link: http://192.168.1.111/TruckService.svc/getAllCompA
from the browser I can access the TruckService.svc file, only the methods throws an error.
The methods is shown from the service help link: http://192.168.1.111/TruckService.svc/help Don't know if that would make a difference?
There isn't a lot of info to work with, I did Google the error but cannot seem to find a similar issue.
Any Ideas?
This part of the error message tells you quite a bit, actually:
"The exception message is 'Login failed for user 'IIS APPPOOL\TEST'.'"
You didn't give a whole lot of information in your question, but I'm willing to bet your service is using a SQL database (Login failed for user is a fairly common SQL error).
Assuming your connection string is correct, based on the error you're most likely using integrated security, which means that the service is trying to login to SQL with the credentials it's being run under, in this case IIS APPPOOL\TEST.
If you want to continue using integrated security, then you need to run the application under an account that has the proper permissions to login to the SQL server. Alternatively, you can update the connection string to use a user name and password. Personally, I prefer integrated security.
Finally, did you check server logs for more details as the error suggested?
Added
To see/change the account the application pool is running under, go to IIS Manager (either from the start menu or type inetmgr from a command prompt). In the left hand pane, expand the tree view so you see the Application Pools node, and then click on that.
Select the application pool (in your case, TEST), right click and select "Advanced Settings..." from the context menu.
This will open a new screen, and you can see what account is currently running that application pool:
Click on the ellipses (...) and this will bring up another window where you can set the account:
Click the button for Custom account and then click "Set..").
Finally, enter the account (you will probably need to enter the domain to, like MyCompany\UserName), enter the password, confirm the password and click OK.
Note that if the password ever changes, the application pool will not run until the password is updated via the steps above.
Related
We use entity framework to read from an existing database.
This is a simplified version of our code.
using (my context context = new mycontext())
{
if(context.Database.Connection.State == System.Data.ConnectionState.Closed)
{
_logger.Info(" Opening the connection to the database");
context.Database.Connection.Open();
}
context.Configuration.LazyLoadingEnabled = false;
IQueryable<mymodel> people;
people = context.People.OrderBy(x => x.Firstname);
_lstContacts = people.ToList();
if (context.Database.Connection.State != System.Data.ConnectionState.Closed)
{
context.Database.Connection.Close();
context.Database.Connection.Dispose();
_logger.Info(" Connection to the database Closed");
}
}
It works 100% of the time, but...
On our UAT environment we can see failed connections to the Microsoft SQL server with the error:
Login failed for user "my user". Reason: Failed to open the explicitly
specified database "null". Client my IP.
For us, these are ghost connections because at the time when we see the errors in the SQL server, our code is not executed.
Initially we didn't close and open the connection explicitly, we just added it trying to control when EF open and closes the connection, but it didn't fix the issue.
Our connection string is using the following format:
<add name="MYCN" connectionString="metadata=res://*/CVs.Cvs.csdl|res://*/CVs.Cvs.ssdl|res://*/CVs.Cvs.msl;provider=System.Data.SqlClient;provider connection string="data source=myserver\;initial catalog=mydatabase;Integrated Security=;User ID=myuser;Password=XXXXXXX;MultipleActiveResultSets=True;App=EntityFramework"/>
As you can see, we are specifying the database in the connection string and our user only have access to our database, so we understand the error when EF doesn't include the database in the connection string, but we don't understand why it's trying to perform these connections.
We know the connections are coming from our application, because we are the only one using that specific user, the IP is the IP of our server, and because the logs in SQL server tell us that the application is "EntityFramewrok"
I didn't personally see the error before, but researched for you and seen that many people suffered from the same problem discussed here: https://blogs.msdn.microsoft.com/sql_protocols/2006/02/21/understanding-login-failed-error-18456-error-messages-in-sql-server-2005/
I read all the messages in the website specified, and here are the solutions offered and at least one other user confirmed that it worked. You might not use 2005 as you didn't specify your version in your question, some solutions I believe will still work for you. Try the list below.
Solution list:
1) Please check the state number of this error and search solution by the state number in addition to the message, might give your more accurate solution proposals. Most common states are listed:
All state-error descriptions you can find here: https://sqlblog.org/2011/01/14/troubleshooting-error-18456
2) Make sure the username and password are correct.
3)
Logon to SQL Server using windows authentication.
Right click in the query window that appears and select "Open Server in Object Explorer"
Go to object explorer and open the "Security" folder and then the "Logins" folder.
Double-click the "sa" user and change the password. Also, like another user mentioned above, untick the "Enforce Password Policy" in
addition to resetting the password.
4) Try to change the password and turn off the policy, and try with new password.
exec sp_password #new = ‘sqlpassword’, #loginame = ‘sa’
alter login sa
with password = ‘sqlpassword’ unlock,
check_policy = off,
check_expiration = off
5) Run your application/browser and SSMS (if you work on it) in administration mode.
6)
Open Windows Services
Configure Microsoft Single Sign-on Service to use the proper account
Open Central Administration >> Operations >> Manage settings for single sign-on
Configure properties to use the same account used for Microsoft ‘Single Sign-on Service
7) Go to Sql server configuration manager and Enable TCP/IP and named pipes
8)
go to sql server
right click on server, choose properties
click on security
on server authentication, enable SQL Server authentication
These might help:
https://www.wikitechy.com/errors-and-fixes/sql/login-failed-error-18456-severity-14-state-38-reason-failed-to-open-the-explicitly-specified-database
https://dba.stackexchange.com/questions/90445/login-failed-for-user-error-18456-severity-14-state-38
I think this is just an access issue for myuser in the UAT environment. Just make sure myuser has access in the UAT environment for UAT database and you should be good.
We've got an ASP.NET application which connects to our database. We handle this connection using an XML config file which contains information with how access the database (username, password, etc). However when we try to access certain pages we're greeted with the yellow screen of death and a message saying Login failed for user xxx.
When run locally as localhost this error does not appear. When we deploy our service to the server this error message appears. Our connection string looks like this:
<add key="DBConnection" value="Data Source=[ServerNameHere];Initial Catalog=[DBNameHere];MultipleActiveResultSets=True;User Id=[usernamehere];Password=[passwordhere];" />
For our SQL Server we've got both SQL Server and Windows Authentication mode enabled. I've checked the login properties for the sa account and changed the "Permission to connect to the database engine" set to "Grant" and the "Login" is set to "Enabled", both of which still present the same issue. The server and database are on the same machine also.
These were the most common resolutions to others who had the same issue, is there something else we can try to fix the issue?
One final note is that when we get the Loging failed for user xxx, the xxx is the name of the machine, so it looks like Domain\MachineName$ when we get the yellow screen of death.
EDIT: The exception being thrown is the following:
System.Data.SqlClient.SqlException: Login failed for user 'Domain\MachineName$'. I've disabled "continue on exception" in my Visual Studio but this error is nowhere to be found when debugging the application locally.
Ok so it turns out the issue was that our IIS Manager which was hosting the service for our web application did not have the correct permission to access the database. To resolve the issue it required going into SQL Manager and adding both a login AND user for our app pool...
Open SQL Server Management Studio and connect to your target server
Under your server expand the Security folder, right click Login and select New Login...
Keep Windows Authentication enabled. The login name should be IIS APPPOOL\[NAME OF YOUR SERVICE HOSTED ON IIS]
Click on the Server Roles link on the left of the screen and ensure that public and sysadmin is selected.
Click on the User Mapping link on the left of the screen and select the DB you'd like your web service to be able to reach.
Click on the Status link on the left and ensure that the settings are set to Grant for permission to connect to the DB and Enabled for the login.
Now create a user for the db you'd like to access...
Expand your chosen DB and expand the Security folder (not to get confused with the security folder above!). Right click it and select New User...
Ensure the user type is SQL user with login (may change depending on how your project is accessing the DB)
To the left of the Login name box there will be a button with ... on it, click it
This brings up a new window. Click on it and then select the login you created previously. Ok all the windows.
Copy and paste the login name as the username
On the left select Owned Schemas and ensure db_reader and db_writer are selected
On the left select Membership and ensure that db_reader and db_writer are selected
Click ok to create the user; your app pool hosting your service should now be able to access the DB
I am replacing MS Word MergeFields with data from SQL Server in a simple asp.net c# application and it works fine locally but when i publish it often i get the following:
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {00020906-0000-0000-C000-000000000046} failed due to the following error: 80080005.
I tried giving both IIS_IUSRS and NETWORK SERVICE full access, and also set the identity to interactive in the DCOM config but it didn't fix anything.
For nasty permissions stopping you from doing what you expect, (I've encountered in the past too). Sometimes I've had to change my DCOM/COM+ permissions to an object too. At the DCOM Config tab screen for your project, under security, make sure BOTH "Launch and Activation" and "Access" have been customized to explicitly include the user account you intend to allow.
Now, one more thing -- just to rule out all others. I've even gone the extent (for testing / confirmation only) is that on the "Identity" tab, you can select the "Interactive User", "Launching User" or "This User". I would put in your actual account that you KNOW has permissions (ensure your account is also in the launch and activation... and access permissions on previous tab). And also to enter/confirm your password.
If that still fails, then I would try adding the ADMIN account for permissions and try that... just for purposes of yes, its permissions based on a user. Once confirmed, you can scale it back, and even create some simplified restricted user who's primary purpose is to run this utility, and this new user has its adequate permissions to do so.
Once that is done, you should be good to go.
Now, that said, I've run into another flakey thing and its been a while, so it may not be an issue any more. Periodically, during certain "Windows" updates, the functionality would just stop working. However, if all I did was go back into user maintenance, do change password for the account (even if just keeping it the same original password) and saving it, then going back into DCOM and enter/re-confirm saving it there too, all became functional again.
You should share the folder where you save the document that is created from the template with the NETWORK SERVICE user.
Change the dcomcnfg identity to interactive instead of launching user.
Reference: Error : 80070005, there is something in this forum about
Retrieving the COM class factory for component with CLSID {7979FAA5-3A2A-4E50-A2C9-286C6F34C1D3} failed due to the following error: 80080005
I am working on development machine without making any user account [i have three of four account who comes when i installed them].
so i open the connection everywhere by a globals variable who hold the connectionstring off-course value of variable can not be changed it's constant.
i open the connection using root account who come by default in mysql server. they work fine everywhere.
but my code try to run a command then server return the error that
The user specified as a definer ('admin'#'localhost') does not exist
i don't know why i got this error even in debug i found that connection open by root and they work fine everywhere else.
so the problem is why they tell me about admin#localhost even the connection my code open by root.
are their anything my code try to do who need authentication or need admin account even they not have then give me exception.
Are you know that what is gone wrong.
I got this error after DB was moved to another server.
There no such user 'admin' so I got the error.
Solution:
log into mysql as root
grant all on *.* to admin#localhost identified by "s!5_superp#ss!";
flush privileges;
I have SQL Server 2008 Enterprise edition, and C# code that should connect to said server. It's a local server on my computer and when I try to log on I get this error:
Cannot open database "Clients" requested by the login, the login failed.
Login failed for user crmsys.
This user has the right permissions, this server is even configured to allow remote connections and through the management studio I can access as this user.
Here's my connection string:
Data Source=./; Initial Catalog=Clients;user ID=crmsys;Password= Password;
In your snippet of configuration settings in your initial post there is a space between the equals sign and the first character of the password - is this correct?
i'm not sure "./" is a valid datasource. I always use "localhost" or ". \ [instancename]"
just an idea.
Make sure you dont have a firewall blocking you; the windows one does by default... If thats all ok check remote connections are enabled: From management studio Check Properties, Connections, and check "Allow Remote Connections To This Server" is checked.
If that is checked then restart SQL Server and try again; if it still fails check that TCP/IP is enabled and the settings using the Configuration Manager.
Are you sure the crmsys user has permission to connect to the database?
If you right-click the "Clients" database entry in SSMS, then go to "Properties" -> "Permissions", then select the "crmsys" user from the "Users or roles" pane, and then click the "Effective" tab, can you confirm that the "CONNECT" permission is there?
Edit: it should look like the image below:
alt text http://img42.imageshack.us/img42/4696/ssms.png
Have you tried Server=.\sqlexpress;Database=Clients;Uid=crmsys;Password=Password;Integrated Security=false
Solved it!!!!!! that was very weird but guess it turned out to be a conflict in the db properties, it's mixed out with the previues user which was crmsys(on the first computer) and when i restored it into my computer i made allready a user name crmsys - delete the user from the DB, deleted the Login crmsys, restored it and then opened a new user with the same permissions, and that it! Thanks you all for helping me figuring it out!