<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Wrong value in connection_property('osuser') in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825647#M4856490</link>
    <description>&lt;P&gt;No, the connection is kept open for the next piece of work from User 1.&lt;/P&gt;
&lt;P&gt;I'm not sure if we are talking about the same thing when mentioning "connection pooling". Our application keeps a set of database connections, to reduce the overhead of reconnecting. Each connection is reserved for use to a specific OS user. After some idle time connections are closed. Though we sometimes call this "connection pooling" (since this is what we do) we do not use the ConnectionPool parameter of Anywhere.&lt;/P&gt;
&lt;P&gt;BTW, Miro an I are colleagues, we're both working on this issue.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jan 2021 03:43:52 GMT</pubDate>
    <dc:creator>former_SQLA_member1694901</dc:creator>
    <dc:date>2021-01-20T03:43:52Z</dc:date>
    <item>
      <title>Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaq-p/13825638</link>
      <description>&lt;P&gt;I use a program that uses impersonate to log into the SQL Anywhere database. The registration (with integrated login) works fine. The mapped user is selected. The osuser is set correctly when logging in for the first time. But this osuser remains the same for the following logins with different integrated users. The AppInfo also has this old user. Can it be cached somehow? Or is the a possibility to get the originating user for integrated login (login mappings)?&lt;/P&gt;
&lt;P&gt;Let me be a bit more precise on what our program is doing:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;List item&lt;/LI&gt;
&lt;LI&gt;A thread is started in the Local System user context&lt;/LI&gt;
&lt;LI&gt;When a "piece of work" arrives from "User1"&lt;/LI&gt;
&lt;LI&gt;The thread impersonates as "User1" and opens a database connection using integrated login. This works well.&lt;/LI&gt;
&lt;LI&gt;After the piece of work is done the thread reverts back to Local System&lt;/LI&gt;
&lt;LI&gt;A second piece of work arrives from "User 2"&lt;/LI&gt;
&lt;LI&gt;The thread impersonates as "User2"&lt;/LI&gt;
&lt;LI&gt;Since the users are different, the program does not re-use the existing connection but opens a new database connection, once more with integrated login.&lt;/LI&gt;
&lt;LI&gt;The database connection is opened, User2 is mapped to the correct database user (which is different from the one User 1 is mapped to), but connection_property('osuser') returns "User 1".&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 19 Jan 2021 08:44:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaq-p/13825638</guid>
      <dc:creator>Miro_Marek</dc:creator>
      <dc:date>2021-01-19T08:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825639#M4856482</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;But this osuser remains the same for the following logins with different integrated users. &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What does that mean, are connections re-used, say via connection pooling?&lt;/P&gt;
&lt;P&gt;We are using integrated logins with v16, and the "OsUser" connection property works as expected, i.e. different OS users are mapped to identical database users, and the OsUser property does return the correct OS user name...&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 09:51:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825639#M4856482</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2021-01-19T09:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825640#M4856483</link>
      <description>&lt;P&gt;Hi Volker,
yes. The program use connection pooling. It is a service for e-mail registration. New user is correctly recognized and used for login. Also th binaries recognize correctly the windows user. Only triggers in the database don´t get the right value. The SQL Anywher version is 17.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 10:02:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825640#M4856483</guid>
      <dc:creator>Miro_Marek</dc:creator>
      <dc:date>2021-01-19T10:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825641#M4856484</link>
      <description>&lt;P&gt;Please tell us &lt;B&gt;exactly what kind of connection pooling&lt;/B&gt; you are using, as discussed in this Help topic &lt;A href="https://help.sap.com/viewer/61ecb3d4d8be4baaa07cc4db0ddb5d0a/17.0/en-US/814d6d5c6ce2101482c9b5abd7938330.html?q=pooling"&gt;&lt;B&gt;Improve Application Performance with Connection Pooling&lt;/B&gt;&lt;/A&gt;; e.g., SQL Anywhere server side pooling versus .NET versus "other pooling product", etc etc etc.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 10:29:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825641#M4856484</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2021-01-19T10:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825642#M4856485</link>
      <description>&lt;P&gt;Just in case you can't get OSUSER to do what you want, setting CON=whatever in the connection string and using CONNECTION_PROPERTY ( 'NAME' ) in the trigger code might help.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 10:36:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825642#M4856485</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2021-01-19T10:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825643#M4856486</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Only triggers in the database don´t get the right value. &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is there a possibility there's "database user impersonation" via SETUSER or via nested procedures at work, i.e. that the (second) connection calls procedure that run in different contexts (see &lt;A href="http://dcx.sap.com/index.html#sqla170/en/html/81891a6e6ce21014808fdbf1c91b03ab.html"&gt;SQL SECURITY DEFINER&lt;/A&gt; etc.) and thereby are mapped to different users? (Note, even if so, I would not know whether this would affect connection property OsUser.)&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 13:09:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825643#M4856486</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2021-01-19T13:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825644#M4856487</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;After the piece of work is done the thread reverts back to Local System&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So that does close the current database connection and give it back to the connection pool?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 13:11:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825644#M4856487</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2021-01-19T13:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825645#M4856488</link>
      <description>&lt;P&gt;We actually do not use CPOOL from connection parameter. This is done with custom code. But as I know the database connection stays open until it is needed for another request.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 13:41:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825645#M4856488</guid>
      <dc:creator>Miro_Marek</dc:creator>
      <dc:date>2021-01-19T13:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825646#M4856489</link>
      <description>&lt;P&gt;&amp;gt; This is done with custom code&lt;/P&gt;
&lt;P&gt;How does that "custom code" work? If you don't know what it is doing, it's unlikely anyone &lt;B&gt;here&lt;/B&gt; will know &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To put it another way, that custom code probably holds the key to your problem.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 14:12:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825646#M4856489</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2021-01-19T14:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825647#M4856490</link>
      <description>&lt;P&gt;No, the connection is kept open for the next piece of work from User 1.&lt;/P&gt;
&lt;P&gt;I'm not sure if we are talking about the same thing when mentioning "connection pooling". Our application keeps a set of database connections, to reduce the overhead of reconnecting. Each connection is reserved for use to a specific OS user. After some idle time connections are closed. Though we sometimes call this "connection pooling" (since this is what we do) we do not use the ConnectionPool parameter of Anywhere.&lt;/P&gt;
&lt;P&gt;BTW, Miro an I are colleagues, we're both working on this issue.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 03:43:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825647#M4856490</guid>
      <dc:creator>former_SQLA_member1694901</dc:creator>
      <dc:date>2021-01-20T03:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825648#M4856491</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Each connection is reserved for use to a specific OS user. &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hm, if this is true, why then do you notice wrong OS user names?&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;If you really do use an existing connection, how would you expect the database server to know that the OS user running the process that uses the same connection has changed in-between? I'm quite sure the APPINFO connection is gathered during the connection's initialization and then kept unchanged.&lt;/P&gt;
&lt;P&gt;A further note: What about temporary tables, connection variables and other connection-specific data - are they "cleaned up" when the according thread ends? AFAIK SQL Anywhere does have to do a lot of "cleaning up" when a connection is given back to the connection pool to make it look like a new one for the next usage, and I guess a home-brewn pooling would have to do the same, if that is possible at all...&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 05:53:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825648#M4856491</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2021-01-20T05:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825649#M4856492</link>
      <description>&lt;P&gt;I agree to your first point, I'd also expect that APPINFO always contains the OS user who &lt;EM&gt;opened&lt;/EM&gt; the connection.&lt;/P&gt;
&lt;P&gt;But we see the wrong OS user in a newly opened second connection. User 2 opens a new connection (in her own user context), because she isn't User 1, otherwise she'd use the existing one.&lt;/P&gt;
&lt;P&gt;Concerning the second paragraph, since every connection is reserved for a specific OS user, it indeed is intended behaviour that nothing is cleaned up! So nothing has to be set up again when the next request comes in.&lt;/P&gt;
&lt;P&gt;Just as background: this implementation originates many years ago, from a time when (AFAIK) connection pooling was not yet supported in Anywhere.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 10:29:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825649#M4856492</guid>
      <dc:creator>former_SQLA_member1694901</dc:creator>
      <dc:date>2021-01-20T10:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825650#M4856493</link>
      <description>&lt;P&gt;Is there any login_procedure "magic" at work?&lt;/P&gt;
&lt;P&gt;You may also try to diagnose the logins via Connect/Disconnect events and/or the LOG connection parameter...&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 10:45:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825650#M4856493</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2021-01-20T10:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong value in connection_property('osuser')</title>
      <link>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825651#M4856494</link>
      <description>&lt;P&gt;&amp;gt; this implementation originates many years ago, from a time when (AFAIK) connection pooling was not yet supported in Anywhere.&lt;/P&gt;
&lt;P&gt;Thank you for that critically important information. &lt;/P&gt;
&lt;P&gt;If you have access to the custom code which implements the connection pooling, please show us the actual code that establishes a new connection to SQL Anywhere that ends up with the wrong value being reported by CONNECTION_PROPERTY ( 'OsUser' );&lt;/P&gt;
&lt;P&gt;If you don't have access to that code (i.e., it is a black box to you) then Volker's suggestions about adding diagnostic code on the database side are good.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 14:16:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/wrong-value-in-connection-property-osuser/qaa-p/13825651#M4856494</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2021-01-20T14:16:03Z</dc:date>
    </item>
  </channel>
</rss>

