Friday, March 30, 2012
Login failed for user NT AUTHORITY\NETWORK SERVICE.
"server=(local);Initial Catalog=myDatabase;Trusted_Connection=yes"
when I run my code, there is an error occur with below message:
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
My SQL Server is configured as Window authentication.
I can't resolve this problem.
Please whow me how to do!
Thank you very much!
You either need to grant the Network Service account access rights toSQL Server, or your application needs to impersonate a specific Windowsuser that has rights to the database.
Wednesday, March 28, 2012
Login failed for user Domainname\computername
Hi,
I am using SQL Server 2005. The below message is added to the Application Event Viewer frequently.
Failure Audit: Login failed for user "abc\xyz$". (Client: xx.xx.xx.xx)
abc is my domain name and xyz is my computer name.
When I look @. the SQL error logs, I find the following message:
Error 18456 Severity 14 state 11
Login failed for user "abc\xyz$". (Client: xx.xx.xx.xx)
Please let me know if you have any suggessions.
Thanks
Santhosh
It seems like a service running in the computer xyz is trying to connect to your SQL Server instance. This service must likely is running with local system or network service credentials.
I would recommend investigating what is this service by verifying the services installed in machine xyz; and if indeed it is a service that should be connecting to that SQL Server instance, you can grant access by creating a login for the Windows user [abc\xyz$] and then grant proper permissions.
I hope this information helps. Let us know if you have any further questions.
Thanks,
-Raul Garcia
SDE/T
SQL Server Engine
|||But, xyz$ is a computer account. How can I create a login for Computer Account in SQL? Is this possible?|||CREATE LOGIN [abc\xyz$] FROM WINDOWS
It should work, let us know if it worked.
Thanks,
-Raul Garcia
SDE/T
SQL Server Engine
|||Hi Raul,
I created the login using the above mentioned command. It created find.
But, now I get two messages in event viewer.
One is success audit where is says login successful for user abc\xyz$.
immeditely, it also logs in the below failure message.
Failure Audit: Login failed for user "abc\xyz$". (Client: xx.xx.xx.xx)
In the earlier posts, you had mentioned about granting permissions to abc\xyz$ account?
What permissions should we grant.
Can you also help me with the syntax to grant those permissions.
Thanks
Santhosh
|||Creating the loginshould typically be enough to connect to the system (using master DB).I would recommend using SLQ Server Profiler and check the Security Events section (mark show all events to see all possibilities), to be more specific mark everything under Audit Login & Audit logout
I hope this helps,
-Raul Garcia
SDE/T
SQL Server Engine
|||We created a login for the computer account name in SQL Server.
From SQL Server, we ran
CREATE LOGIN [Domainname\computername$] FROM WINDOWS
The login created successfully.
Now, we see two audit messages for Domainname\Computername$.
First audit message is..
Login Succeded for user Domainname\Computername$. Connection Trusted.(Client :xx.xx.xx.xx)
Second Audit message is.. Login failed for user Domainname\Computername$. (Client :xx.xx.xx.xx)
Before creating the login, we had only login failed message. But, now we get login succeded message and login failed message for the same username.
Any thoughts would be helpful.
Thanks
Santhosh
|||Unfortunately I really have no idea on what may be happening. I would suggest trying to enable other events, including any permission checks or any queries being started. Hopefully this extra information will give us a clue on why the connection is failing.
-Raul Garcia
SDE/T
SQL Server Engine
Login failed for user Domainname\computername
Hi,
I am using SQL Server 2005. The below message is added to the Application Event Viewer frequently.
Failure Audit: Login failed for user "abc\xyz$". (Client: xx.xx.xx.xx)
abc is my domain name and xyz is my computer name.
When I look @. the SQL error logs, I find the following message:
Error 18456 Severity 14 state 11
Login failed for user "abc\xyz$". (Client: xx.xx.xx.xx)
Please let me know if you have any suggessions.
Thanks
Santhosh
It seems like a service running in the computer xyz is trying to connect to your SQL Server instance. This service must likely is running with local system or network service credentials.
I would recommend investigating what is this service by verifying the services installed in machine xyz; and if indeed it is a service that should be connecting to that SQL Server instance, you can grant access by creating a login for the Windows user [abc\xyz$] and then grant proper permissions.
I hope this information helps. Let us know if you have any further questions.
Thanks,
-Raul Garcia
SDE/T
SQL Server Engine
|||But, xyz$ is a computer account. How can I create a login for Computer Account in SQL? Is this possible?|||CREATE LOGIN [abc\xyz$] FROM WINDOWS
It should work, let us know if it worked.
Thanks,
-Raul Garcia
SDE/T
SQL Server Engine
|||Hi Raul,
I created the login using the above mentioned command. It created find.
But, now I get two messages in event viewer.
One is success audit where is says login successful for user abc\xyz$.
immeditely, it also logs in the below failure message.
Failure Audit: Login failed for user "abc\xyz$". (Client: xx.xx.xx.xx)
In the earlier posts, you had mentioned about granting permissions to abc\xyz$ account?
What permissions should we grant.
Can you also help me with the syntax to grant those permissions.
Thanks
Santhosh
|||Creating the loginshould typically be enough to connect to the system (using master DB).I would recommend using SLQ Server Profiler and check the Security Events section (mark show all events to see all possibilities), to be more specific mark everything under Audit Login & Audit logout
I hope this helps,
-Raul Garcia
SDE/T
SQL Server Engine
|||We created a login for the computer account name in SQL Server.
From SQL Server, we ran
CREATE LOGIN [Domainname\computername$] FROM WINDOWS
The login created successfully.
Now, we see two audit messages for Domainname\Computername$.
First audit message is..
Login Succeded for user Domainname\Computername$. Connection Trusted.(Client :xx.xx.xx.xx)
Second Audit message is.. Login failed for user Domainname\Computername$. (Client :xx.xx.xx.xx)
Before creating the login, we had only login failed message. But, now we get login succeded message and login failed message for the same username.
Any thoughts would be helpful.
Thanks
Santhosh
|||Unfortunately I really have no idea on what may be happening. I would suggest trying to enable other events, including any permission checks or any queries being started. Hopefully this extra information will give us a clue on why the connection is failing.
-Raul Garcia
SDE/T
SQL Server Engine
Friday, March 23, 2012
login failed for user (null)
I have .net app got this error below,
Connection failed: sqlstate:28000 sql server error: 18452 login failed for
user(null). reason: not associated with a trusted SQL server connection
Any ideas
thanksYour SQL Server Authenticaton could be Windows Authentication and a user
tries to connect using his\her SQL Server login.
Another possibility, that user might not be a member of your domain and
tries to connect to your SQL Server instance.
Ekrem nsoy
"mecn" <mecn2002@.yahoo.com> wrote in message
news:e45jDthJIHA.3516@.TK2MSFTNGP02.phx.gbl...
> Hi
> I have .net app got this error below,
> Connection failed: sqlstate:28000 sql server error: 18452 login failed for
> user(null). reason: not associated with a trusted SQL server connection
> Any ideas
> thanks
>|||Yeah, he's right. It's trying to connect with a windows acct that doesn't
have rights in the DB. Either give it rights, or switch to sql auth.
"mecn" wrote:
> Hi
> I have .net app got this error below,
> Connection failed: sqlstate:28000 sql server error: 18452 login failed for
> user(null). reason: not associated with a trusted SQL server connection
> Any ideas
> thanks
>
>|||Or the application is trying to connect using Windows Authentication when no
one is logged in, and it doesn't have a user context. I've seen this when
people set it up using Windows Authentication when they are logged in, and
expect it to work when no one is logged in.
--
Rick Byham (MSFT)
This posting is provided "AS IS" with no warranties, and confers no rights.
"Sean McCown" <SeanMcCown@.discussions.microsoft.com> wrote in message
news:2EA9BABD-7F69-4758-BD14-A7809FAB6657@.microsoft.com...[vbcol=seagreen]
> Yeah, he's right. It's trying to connect with a windows acct that doesn't
> have rights in the DB. Either give it rights, or switch to sql auth.
>
> "mecn" wrote:
>|||Hmm.. Good point!
Thanks for sharing.
Ekrem ?nsoy
"Rick Byham, (MSFT)" <rickbyh@.REDMOND.CORP.MICROSOFT.COM> wrote in message
news:6E02C41D-1A5E-4A9A-9218-BC5BF1746759@.microsoft.com...
> Or the application is trying to connect using Windows Authentication when
> no one is logged in, and it doesn't have a user context. I've seen this
> when people set it up using Windows Authentication when they are logged
> in, and expect it to work when no one is logged in.
> --
> Rick Byham (MSFT)
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> "Sean McCown" <SeanMcCown@.discussions.microsoft.com> wrote in message
> news:2EA9BABD-7F69-4758-BD14-A7809FAB6657@.microsoft.com...
>
Wednesday, March 7, 2012
Logical Operators in SQL statement
newLoanSQL = "SELECT LOAN_ID, DEPENDANT_CHILDREN, RESIDENTIAL_STATUS, LOAN_AMOUNT, INTEREST_RATE, DURATION, REPAYMENTS, REPAYMENT_AMOUNT, PURPOSE, OCCUPATION, EMPLOYMENT_STATUS, EMPLOYERS_NAME, ANNUAL_INCOME, SPOUSE_NAME, GUARANTOR, SECURITY, APPROVAL_ONE, APPROVAL_TWO, APPROVAL_THREE FROM LOAN_DETAILS Where NEW_APPLICATION = '" & searchString & "' AND APPROVER1_ID <> '" & id & "' OR APPROVER2_ID <> '" & id & "' OR APPROVER3_ID <> '" & id & "'"
The SQL statement was working fine until I added the following:
AND APPROVER1_ID <> '" & id & "' OR APPROVER2_ID <> '" & id & "' OR APPROVER3_ID <> '" & id & "'
Can anyone help me please?If you mix ANDs and ORs like that you are likely to get the wrong result due to the order in which they get processed. Bracket the ORs together like this:
Where NEW_APPLICATION = ? AND (APPROVER1_ID <> ? OR APPROVER2_ID <> ? OR APPROVER3_ID <> ?)
But is that really what you want? I imagine what you meant was really:
Where NEW_APPLICATION = ? AND (APPROVER1_ID <> ? AND APPROVER2_ID <> ? AND APPROVER3_ID <> ?)
i.e. "the given ID must not appear in ANY of the 3 approver_id columns", rather than "the given ID must not appear in ALL 3 of the approver_id columns (but can appear in 1 or 2 of them)"
Note: I am encouraging you to change to bind variables at the same time. Not only do they make the code more readable and reduce typing errors, they also improve the performance and security of your application.|||I did as suggested by Tony Andrews. However, the SQL statement still is not working.
newLoanSQL = "SELECT LOAN_DETAILS.LOAN_ID, LOAN_DETAILS.DEPENDANT_CHILDREN, LOAN_DETAILS.RESIDENTIAL_STATUS, LOAN_DETAILS.LOAN_AMOUNT, LOAN_DETAILS.INTEREST_RATE, LOAN_DETAILS.DURATION, LOAN_DETAILS.REPAYMENTS, LOAN_DETAILS.REPAYMENT_AMOUNT, LOAN_DETAILS.PURPOSE, LOAN_DETAILS.OCCUPATION, LOAN_DETAILS.EMPLOYMENT_STATUS, LOAN_DETAILS.EMPLOYERS_NAME, LOAN_DETAILS.ANNUAL_INCOME, LOAN_DETAILS.SPOUSE_NAME, LOAN_DETAILS.GUARANTOR, LOAN_DETAILS.SECURITY, LOAN_DETAILS.APPROVAL_ONE, LOAN_DETAILS.APPROVAL_TWO, LOAN_DETAILS.APPROVAL_THREE, LOAN_DETAILS.NEW_APPLICATION, LOAN_DETAILS.APPROVER1_ID, LOAN_DETAILS.APPROVER2_ID, LOAN_DETAILS.APPROVER3_ID FROM LOAN_DETAILS WHERE LOAN_DETAILS.NEW_APPLICATION='Yes' AND (APPROVER1_ID <> '" & sID & "' AND APPROVER2_ID <> '" & sID & "' AND APPROVER3_ID <> '" & sID & "') OR (LOAN_DETAILS.APPROVER1_ID Is Null AND LOAN_DETAILS.APPROVER2_ID Is Null AND LOAN_DETAILS.APPROVER3_ID Is Null)"
Please, can someone help me with this as I am working to a deadline.
Thanks in advance|||NULLs are a problem in SQL too, since they are neither equal to, nor not equal to, anything - including NULL! So perhaps what you need is:
((APPROVER1_ID <> ? OR APPROVER1_ID IS NULL)
AND (APPROVER2_ID <> ? OR APPROVER2_ID IS NULL)
AND (APPROVER3_ID <> ? OR APPROVER3_ID IS NULL))|||All working now! Thanks a million, I really appreciate your help.
Cheers
Friday, February 24, 2012
Logic Behind Object_ID
I have 2 basic requirements as below,
1) Comparing 2 versions of same database.
2) Keeping track of schema versions of Tables & Stored Procedures so that I can rollback to previous schema.
I have started with Sys.Objects, Sys.Tables & Sys.Columns and I kept things rely on Object_ID but the problem started whenever I change some part of Table. It assigns new Object_ID to the table whenever I change it; moreover creationdate of object is also changed. So I assume that it drops and creates new table.
Please throw some light on following questions,
1) When and How Object_ID Changes?
2) Is there any other thing in database which is Unique & Not Changing with alteration of object?
3) What should be the preferred way to Compare 2 Database?
I hate readymade tools as they charge per user and my requirements are very small.
Thanking you,
Object_ID is internal, and can definitely change when you call the ALTER TABLE / ALTER INDEX statements when the engine decides it is easier to create a new object than to modify the existing table.The best way to keep track of different version of tables and stored procedures is to use a source control system (like VSTS/SourceSafe). Each time you load a new version in the database, you store the database script in the source control system. If you need to get back to an old version, you simply get the version from source control.
To compore 2 versions of the same database, you can use VSTS for database professionals, which contains this functionality.
Thanks,|||
Versioning is OK. We can easily maintain with Source Control
But Real Headache is DataBase Comparsion, We cannot afford to go for VSTS so there should be some other alternative.
Can you give a brick (clue) for object_id or anything else using which I can build building?
Thanks
|||Would it be possible to use the table name to compare, or do you need to do compares of tables with different names?Thanks,|||I would definitely use objectname instead of id. Since it's not possible to have to objects with the same name for the same schema. You're guarantee to find the object you're looking for to compare.