rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
605 stars 191 forks source link

TinyTds::Error: User does not have permission #414

Open mohamednazar opened 6 years ago

mohamednazar commented 6 years ago

Environment

Operating System

Windows 2016

TinyTDS Version and Information

PS C:\opscode\chef\embedded\bin> .\tsql-ttds -C
[TinyTds][v2.1.2][tsql]: C:/opscode/chef/embedded/lib/ruby/gems/2.4.0/gems/tiny_tds-2.1.2-x64-mingw32/ports/x86_64-w64-m
ingw32/freetds/1.00.27/bin/tsql.EXE
Compile-time settings (established with the "configure" script)
                            Version: freetds v1.00.27
             freetds.conf directory: C:/Sites
     MS db-lib source compatibility: no
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 7.3
                              iODBC: no
                           unixodbc: no
              SSPI "trusted" logins: yes
                           Kerberos: no
                            OpenSSL: yes
                             GnuTLS: no
                               MARS: no

Gem Version

PS C:\opscode\chef\embedded\bin> .\gem --version 2.6.11

Description

I am executing a sql query using tiny_tds, the query executing fine if I manually execute and not when execute via chef-client this issue is not permanent and sometimes same query is working and sometimes not. I am unable to find what causing the issue.

Below is the various kind of errors:

Error1:

TinyTds::Error: ruby_block[Model-DB-Recovery-Simple] (SqlServer::Model-DB line 20) had an error: TinyTds::Error: User does not have permission to alter database 'model', the database does not exist, or the database is not in a state that allows access checks.

Error2:

[2018-06-05T18:37:55+00:00] FATAL: TinyTds::Error: ruby_block[Additional_Configuration] (SqlServer::Additional_Configuration line 20) had an error: TinyTds::Error: User does not have permission to perform this action.

In both error it says "User does not have permission to perform this action." In same time other queries working via tiny_tds. Please help me to resolve it.

Regards, Mohamed Nazar

metaskills commented 6 years ago

I am almost certain this has nothing to do with TinyTDS but rather the permissions of the user in the database. For example, connecting as sa would almost certainly work. You will need to make sure the user that you are connecting with has the permissions needed to do the SQL/DDL required.