Results 1 to 19 of 19

Thread: What's wrong with this connection string?

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2015
    Posts
    38

    What's wrong with this connection string?

    Hi,

    I'm using a service account, non-windows authentication.



    Code:
    Set Connection_o = CreateObject("ADODB.Connection")
    
    ' ConnectionString_s = "Provider=SQLOLEDB;Data  Source=XXXXXXXXXXXXX\YYYYYYYYYY:99999;database=XXXXXXXXXXX;User ID=SVC\XXXXXXX;Password=YYYYYYYYYYYYYYYYYYYY"
    ConnectionString_s = "Provider=SQLNCLI11;Data 
    Source=XXXXXXXXXXXXX\YYYYYYYYYY:99999;database=XXXXXXXXXXX;User ID=SVC\XXXXXXX;Password=YYYYYYYYYYYYYYYYYYYY"
    'SQLSRV32.DLL
    'SQLNCLI11'
    
    Connection_o.Open ConnectionString_s

    , but it returns invalid parameters or connection string not valid.

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,630

    Re: What's wrong with this connection string?

    Assuming the :99999 in "Source" represents a non-standard port, try replacing the : (colon) with a , (comma)

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: What's wrong with this connection string?

    Port numbers don't go that high.

  4. #4
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,630

    Re: What's wrong with this connection string?

    Quote Originally Posted by dilettante View Post
    Port numbers don't go that high.
    ...And all of the XXXXX and YYYYY are obviously placeholders for the actual connection information as well...

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: What's wrong with this connection string?

    Code:
    User ID=SVC\XXXXXXX;Password=YYYYYYYYYYYYYYYYYYYY"
    You have two types of authentication ... Windows, and SQL Login ... One uses the currently logged in user and determines if they have access... that would be a Windows authentication ... the other you supply a user name and a password, and that determines if access is granted ... that would be a SQL Login...
    Your connection string indicates a user and password ... which would indicate a SQL Login ... but using "SVC\XXXX" looks like a service user... which wouldn't be a SQL Login ....

    Bottom line is it looks like a mismatched connection string. Possibly. Not a lot of info to go on.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2015
    Posts
    38

    Re: What's wrong with this connection string?

    Thanks everyone,

    I think one of my problems is that I don't understand the concept of a Service Account. I tried to look it up on Google, but many of the definitions are circular. I'll try a Youtube video.

    Since a Service Account has an id and password, I assumed that it's not Windows authentication. Is that wrong?

    I was told that this could only be used programmatically. That you can't log into SSMS with it, even if you login with a different user.

    The port isn't 99999, that's just a placeholder. But it IS 5 digits, beginning with 50.

    So these are the specs that they gave me:

    SERVER/INSTANCE = SSSSSSS\IIIIIII:50999
    Service account = SVC\SASASASA
    pw = PPPPPPPPPPPP
    Database = DBDBDBDB

    Is there a provider which is preferable? SQLOLEDB or SQLNCLI11?
    Last edited by VBExplorer12; Dec 14th, 2022 at 07:04 AM.

  7. #7
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: What's wrong with this connection string?

    I'm septical on the provider. I don't know if it is needed that way or it will bug out. Also not using ports.
    Here is 2 datasources I use , one for console app and one for web app:
    "Data Source=TestServer;Initial Catalog=Jerkface;User Id=Jer; Password=YesOfCourse;" providerName="System.Data.SqlClient"

    web config line:
    <add name="C30" providerName="System.Data.SqlClient" connectionString="Data Source=MAINSRV;Initial Catalog=MEGA;Integrated Security=False;User Id=MEGAJERK;Password=YeDreamOn;MultipleActiveResultSets=True;Pooling=False;" />
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  8. #8

    Thread Starter
    Member
    Join Date
    Dec 2015
    Posts
    38

    Re: What's wrong with this connection string?

    Thanks sapator, I tried this approach but it says that "Data source name not found and no default driver specified."


    OptionBase1, you're correct about separating the port with a comma, rather than a colon.


    In another script, the below works fine. But it's not for a service account.


    Code:
    Connection_o.Open "Provider=SQLOLEDB ; ApplicationIntent=ReadOnly ; Data Source=SSSSSSSSSSS\IIIIII,99999 ; Trusted_Connection=Yes ; Initial Catalog=acctpayable ; Integrated Security = SSPI ;"

    For the service account, I tried the one below. It returns an error 'invalid connection string attribute', and says 'These workstations have sessions with open files on this server:'


    Code:
    ConnectionString_s = "Provider=SQLOLEDB ; ApplicationIntent=ReadOnly ; Data Source=SSSSSSSSSSSSS\IIIIIIIIII,99999 ; Trusted_Connection=Yes ; Initial Catalog=DBDBDBDBDBD ; Integrated Security = SSPI ; User ID=SVC\SASASASASASASASASA;Password=PPPPPPPPPPPPPPPPPPPPPPPPP"
    Last edited by VBExplorer12; Dec 14th, 2022 at 10:25 AM.

  9. #9
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,630

    Re: What's wrong with this connection string?

    I didn't look this up or anything, but it seems wrong to specify "SVC\" in front of the username.

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: What's wrong with this connection string?

    Quote Originally Posted by VBExplorer12 View Post
    Thanks sapator, I tried this approach but it says that "Data source name not found and no default driver specified."


    OptionBase1, you're correct about separating the port with a comma, rather than a colon.


    In another script, the below works fine. But it's not for a service account.


    Code:
    Connection_o.Open "Provider=SQLOLEDB ; ApplicationIntent=ReadOnly ; Data Source=SSSSSSSSSSS\IIIIII,99999 ; Trusted_Connection=Yes ; Initial Catalog=acctpayable ; Integrated Security = SSPI ;"

    For the service account, I tried the one below. It returns an error 'invalid connection string attribute', and says 'These workstations have sessions with open files on this server:'


    Code:
    ConnectionString_s = "Provider=SQLOLEDB ; ApplicationIntent=ReadOnly ; Data Source=SSSSSSSSSSSSS\IIIIIIIIII,99999 ; Trusted_Connection=Yes ; Initial Catalog=DBDBDBDBDBD ; Integrated Security = SSPI ; User ID=SVC\SASASASASASASASASA;Password=PPPPPPPPPPPPPPPPPPPPPPPPP"
    The ifrst one use the Windows Authentication ... that's where it logs in as the process's user ... which could be a User, OR A Svc Account (at least it should be).

    The second one is using SQL Server Authentication ... and unless there's an actual SQL Login called "SVC\XXXXXX" then yeah, it's not going to work.

    Really, you should be looking at the Logins on the SQL Server itself, find that user, and see if it's using SQL Authentication (there will be a Login associated with it) or a Windows Authentication (there will be a windows user associated with it).

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11

    Thread Starter
    Member
    Join Date
    Dec 2015
    Posts
    38

    Re: What's wrong with this connection string?

    I'm not sure I have permissions to check the logins directly on the server.

    Anyway, a .net login seems to indicate this is Windows Authentation


    "ConnectionStrings": {
    "DefaultConnection": "Server=SSSSSSSSSSSSS.svc.st.gov\\IIIIIIIIII,50999;database=DDDDDDDDDDD;trusted_connection=true" ,
    "DefaultConnectionSchemaName": "dbo"
    },

    Identity: SVC\SASASASASA


    I got a little further this time, on the vbs side:

    Code:
    ConnectionString_s = "Provider=SQLNCLI11 ; Data Source==SSSSSSSSSSSSS.svc.st.gov\\IIIIIIIIII,99999;database=DDDDDDDDDDD;Integrated Security = SSPI;DefaultConnectionSchemaName=dbo"

    This time, the response wasn't immediate, but it was another Invalid connection string attribute. Probably the DefaultConnectionSchemaName.

  12. #12
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: What's wrong with this connection string?

    use a single \, not \\ the \\ hapens in the json snip because it needed to be escaped. In the string in your connection string, it does not.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13

    Thread Starter
    Member
    Join Date
    Dec 2015
    Posts
    38

    Re: What's wrong with this connection string?

    No, I'm wrong. It didn't go any further. I put in a double '=' sign in there, and it just took longer to process.

    This one at least tells me the service credentials don't belong there, I guess because it's being interpreted as an ordinary user which conflicts with Windows Authentication.

    Code:
    ConnectionString_s = "Provider=SQLNCLI11 ; Data Source=SSSSSSSSSSSSS.svc.st.gov\IIIIIIIIII,99999;database=DDDDDDDDDDD;Integrated Security = SSPI;User ID=SVC\SASASASASASASASASA;Password=PPPPPPPPPPPPPPPPPPPPPPPPP"
    Returns
    "Login failed for user 'SVC\Dddddd2' (Ddddd2 is my identity on the PC where I'm running the VBScript)."

    So, I still don't understand - and can't find on the web - how to log into Sql Server with a Service Account. I have no problem logging in, any other way.

  14. #14

    Thread Starter
    Member
    Join Date
    Dec 2015
    Posts
    38

    Re: What's wrong with this connection string?

    Quote Originally Posted by techgnome View Post
    use a single \, not \\ the \\ hapens in the json snip because it needed to be escaped. In the string in your connection string, it does not.

    -tg
    Yep, I know techgnome. I had accidentally copied the double-slash from the .net string.

  15. #15

    Thread Starter
    Member
    Join Date
    Dec 2015
    Posts
    38

    Re: What's wrong with this connection string?

    I also tried RunAs with the script, and it says that the user has not been granted the requested logon type at this computer.

    I also tried the same thing on a remote PC, and got the same result.

  16. #16
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: What's wrong with this connection string?

    Quote Originally Posted by VBExplorer12 View Post
    No, I'm wrong. It didn't go any further. I put in a double '=' sign in there, and it just took longer to process.

    This one at least tells me the service credentials don't belong there, I guess because it's being interpreted as an ordinary user which conflicts with Windows Authentication.

    Code:
    ConnectionString_s = "Provider=SQLNCLI11 ; Data Source=SSSSSSSSSSSSS.svc.st.gov\IIIIIIIIII,99999;database=DDDDDDDDDDD;Integrated Security = SSPI;User ID=SVC\SASASASASASASASASA;Password=PPPPPPPPPPPPPPPPPPPPPPPPP"
    Returns
    "Login failed for user 'SVC\Dddddd2' (Ddddd2 is my identity on the PC where I'm running the VBScript)."

    So, I still don't understand - and can't find on the web - how to log into Sql Server with a Service Account. I have no problem logging in, any other way.
    You use this:
    Integrated Security = SSPI;
    OR this
    User ID=SVC\SASASASASASASASASA;Password=PPPPPPPPPPPPPPPPPPPPPPPPP

    Not both...


    As I think about it more ... I don't think you can use the service login ... the service logins are local to the machine if I remember right. It's the context the under which services on that computer will run. And I don't think they are transferrable. The reason I'm thinking this is is because they're not an AD account ... which is what SQL Server sees (besides the accounts local to that server).

    maybe tilting windmills here...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  17. #17

    Thread Starter
    Member
    Join Date
    Dec 2015
    Posts
    38

    Re: What's wrong with this connection string?

    Yep, I understand techgnome. I thought that maybe the service account credentials were exceptional somehow, especially since the .net version has trusted_connection=true.

    This obviously has to be executed via RunAs.

    I'll ask my manager for a workstation where the service credentials can be run. I think he told me that I was in the group, but they are wrong about this many times.

  18. #18
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,630

    Re: What's wrong with this connection string?

    I think your over-exuberant placeholder modification of the connection string is really, really muddying the waters here.

    Earlier you said this:

    "Login failed for user 'SVC\Dddddd2' (Ddddd2 is my identity on the PC where I'm running the VBScript)."
    But then you keep making mention of trying to log in with a service account. So which is it? Are you using your own Windows user account credentials in the connection string?

    And it still isn't clear what the "SVC" prefix you are using for the credentials is attempting to represent here. Is it the host name of the server that you are connecting to? Is it your local workstation name? Is it the NetBios name of the Active Directory domain that everything is joined to? Is it the SQL Server instance name?

    While it is possible that the root cause is a lack of permissions, I'm not convinced that is the case. If you could provide more specific details answering the questions I pose above, then you might get pointed in the right direction.

    Good luck.

  19. #19

    Thread Starter
    Member
    Join Date
    Dec 2015
    Posts
    38

    Re: What's wrong with this connection string?

    Quote Originally Posted by OptionBase1 View Post
    I think your over-exuberant placeholder modification of the connection string is really, really muddying the waters here.

    Earlier you said this:



    But then you keep making mention of trying to log in with a service account. So which is it? Are you using your own Windows user account credentials in the connection string?

    And it still isn't clear what the "SVC" prefix you are using for the credentials is attempting to represent here. Is it the host name of the server that you are connecting to? Is it your local workstation name? Is it the NetBios name of the Active Directory domain that everything is joined to? Is it the SQL Server instance name?

    While it is possible that the root cause is a lack of permissions, I'm not convinced that is the case. If you could provide more specific details answering the questions I pose above, then you might get pointed in the right direction.

    Good luck.
    SVC IS the first 3 letters of the service login account. Ddddd2 is my local account.

    At any rate, I got an answer. It woudn't have been possible to do this locally.


    "I did talk to XXXX about this issue. Per XXXX, you won’t be able to connect to the SQL DB directly from SSS using a windows service account. For .Net apps, we are connecting to DB via IIS app pool. Is there anything similar in SSS? If not, we may have to check with DB team for a local DB account."

    The weblogic server that connects is running from a linux server.

    The person who asked me about this originally, is building a Java app and can't figure out how to connect to the database with the service account provided. I told them I would try from a different environment - VBScript - but of course was unsuccessful. There was also a .net app that connected successfully, but of course it's not going to work from our angle.


    Thanks everyone for trying to help. The java developer is pointed in the right direction. Resolved.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width