<p>How do I get ms-access to connect (through ODBC) to an ms-sql database as a different user than their Active Directory ID? </p>

<p>I don't want to specify an account in the ODBC connection, I want to do it on the ms-access side to hide it from my users. Doing it in the ODBC connection would put me right back in to the original situation I'm trying to avoid.</p>

<p>Yes, this relates to a previous question: <a href="http://www.stackoverflow.com/questions/50164/">http://www.stackoverflow.com/questions/50164/</a></p>

[{'answer_id': 51016, 'author': 'tbreffni', 'author_id': 637, 'author_profile': 'https://Stackoverflow.com/users/637', 'pm_score': 0, 'selected': False, 'text': '<p>I think you\'d have to launch the MS Access process under the account you want to use to connect.  There are various tools that let you do this, such as <a href="http://www.joeware.net/freetools/tools/cpau/index.htm" rel="nofollow noreferrer">CPAU</a>.  This tool will let you encrypt the password as well.</p>\n'}, {'answer_id': 73412, 'author': 'Philippe Grondier', 'author_id': 11436, 'author_profile': 'https://Stackoverflow.com/users/11436', 'pm_score': 0, 'selected': False, 'text': '<p>We admit here that you are using an ODBC connexion to your database with Integrated Security on, so that you do not have/do not want to write a username/pasword value in the connexion string (which is according to me the right choice).</p>\n\n<p>In this case, there is fortunately no way to "simulate" another user when connecting to the data. Admit with me that being able to make such a thing would be a huge break in integrated security! </p>\n\n<p>I understood from your previous post that you wanted users to be able to update the data or not depending on the client interface they use. According to me, the idea would be to create for each table a linked \'not updatable\' view. Let\'s say that for each table called <code>Table_Blablabla</code> you create a view (=query in Access) called <code>View_Table_Blablabla</code> ...). </p>\n\n<p>When using Access, you can then decide at runtime wether you want to open the updatable table or the read-only view. This can be done for example at runtime, in the <code>form_Open</code> event, by setting the form recordsource either to the table or the view.</p>\n'}, {'answer_id': 77791, 'author': 'BIBD', 'author_id': 685, 'author_profile': 'https://Stackoverflow.com/users/685', 'pm_score': 0, 'selected': False, 'text': "<p>@Philippe<br>\nI assume that you are using the word <strong>admit</strong> as being roughly equivalent to <strong>understand</strong> or perhaps <strong>agree</strong>; as opposed to the opposite of <strong>deny</strong>.</p>\n\n<p>I understand the implications of having all the users login to the database using one ID and password (and having them stored in the application). That to me is a smaller risk than the problem I'm facing right now.<br>\n@off</p>\n\n<p>Some more background to the problem:\nI have ODBC connections set up on each of the users workstations using Windwos NT authentication. Most of the time the users connect using an MDE setup to use that ODBC connection - in this case they ALWAYS have the ability to add/update/delete data.</p>\n\n<p>The problem comes that some of the users are educated enough about MS-Access to create a new mdb and link it to the MS-SQL server. They can then edit the data right within the tables rather than going through the application which does a certain amount of validation and hand holding. And they <strong>like</strong> doing this, but sometimes the mess it up and cause me problems.</p>\n"}, {'answer_id': 85064, 'author': 'BIBD', 'author_id': 685, 'author_profile': 'https://Stackoverflow.com/users/685', 'pm_score': 0, 'selected': False, 'text': '<p>What I was hoping to do (which I just experimented with) was to refresh the links to the database something like this for each table (Note: I\'ve switched the ODCB connection to SQL Server authentication for this experiment, and added the accounts to the SQL server as well: <strong>readonly</strong> - which can\'t to any updates, and <strong>readwrite</strong> - which has full privileges on the table).</p>\n\n<pre><code>myTable.Connect = _\n                "ODBC;" &amp; _\n                "DATABASE=" &amp; "MyTestDB" &amp; ";" &amp; _\n                "UID=readonly;" &amp; _\n                "PWD=readonly_password;" &amp; _\n                "DSN=" &amp; "MyTestDB" &amp; ";"\nmyTable.RefreshLink\n</code></pre>\n\n<p>this stops them from editing, but I can\'t get a later readwrite to work</p>\n\n<pre><code>myTable.Connect = _\n                "ODBC;" &amp; _\n                "DATABASE=" &amp; "MyTestDB" &amp; ";" &amp; _\n                "UID=readwrite;" &amp; _\n                "PWD=readwrite_password;" &amp; _\n                "DSN=" &amp; "MyTestDB" &amp; ";"\nmyTable.RefreshLink\n</code></pre>\n\n<p>It seems that whichever permission I connect with first, sticks permenantly. If I started readwrite and then go to readonly, the table remains with the readwrite privileges</p>\n'}, {'answer_id': 153206, 'author': 'Tim Lentine', 'author_id': 2833, 'author_profile': 'https://Stackoverflow.com/users/2833', 'pm_score': 4, 'selected': True, 'text': '<p>I think you can get this to work the way you want it to if you use an <a href="http://www.carlprothman.net/Default.aspx?tabid=90#ODBCDriverForSQLServer" rel="noreferrer">"ODBC DSN-LESS connection"</a></p>\n\n<p>If you need to, keep your ODBC DSN\'s on your users\' machines using windows authentication. Give your users read-only access to your database. (If they create a new mdb file and link the tables they\'ll only be able to read the data.)</p>\n\n<p>Create a SQL Login which has read/write permission to your database.</p>\n\n<p>Write a VBA routine which loops over your linked tables and resets the connection to use you SQL Login but be sure to use the "DSN-Less" syntax.</p>\n\n<pre><code>"ODBC;Driver={SQL Native Client};" &amp;\n       "Server=MyServerName;" &amp; _\n       "Database=myDatabaseName;" &amp; _\n       "Uid=myUsername;" &amp; _\n       "Pwd=myPassword"\n</code></pre>\n\n<p>Call this routine as part of your startup code. </p>\n\n<p><strong>A couple of notes about this approach:</strong></p>\n\n<ul>\n<li><p>Access seems to have an issue with the connection info once you change from Read/Write to Read Only and try going back to Read/Write without closing and re-opening the database (mde/mdb) file. If you can change this once at startup to Read/Write and not change it during the session this solution should work.</p></li>\n<li><p>By using a DSN - Less connection you are able to hide the credentials from the user in code (assuming you\'re giving them an mde file you should be ok). Normally hard-coding connection strings isn\'t a good idea, but since you\'re dealing with an in-house app you should be ok with this approach.</p></li>\n</ul>\n'}, {'answer_id': 211338, 'author': 'Jason', 'author_id': 26347, 'author_profile': 'https://Stackoverflow.com/users/26347', 'pm_score': 0, 'selected': False, 'text': "<p>Why not use integrated/windows security.  You can grant an active directory group the rights you want the users and then add the users accounts to that group.  I believe you can also use sql server's roles feature in addition to this to limit functionality based on the client application being used.</p>\n"}]
['https://Stackoverflow.com/questions/50786', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/685/']