Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DSN Rights Problem

Status
Not open for further replies.

Webflex

Technical User
Apr 20, 2001
101
GB
Hi, I have just moved from a DSNLess connection to try and resolve some provider error messages I was getting. However the problem I have now is that the code below will run quite happily with admin rights but when I use a user account I get the dreaded '800004005' [ODBC Driver Manager]Data Source name not found and no default driver specified.

This runs in an NT Authenticated environment, anonymous is disabled and the iusr_machine account is not used.

I thought System DSN's were available to all users so although this seems like a rights issue I do not understand where it is coming from. Any help greatly appreciated.

End of the day in Europe so will not see replies until tomorrow.

TIA

Code:
<%option explicit
dim dsn,conn,rs,sql,x
dim flag,color,useraction,element
useraction=request.querystring(&quot;action&quot;)
select case useraction
case &quot;search&quot;
	x = 0
	sql = &quot;select * from users where id>0&quot;
	dsn=&quot;CSOLPhone&quot;
	set conn = server.createObject(&quot;adodb.connection&quot;)
	set rs = server.createObject(&quot;adodb.recordset&quot;)
	conn.open dsn
	
	for each element in request.form

	if request.form(element)<>&quot;&quot; then
	
		select case element
			case &quot;tel&quot;
			sql=sql & &quot; and tel = '&quot;  & Request.form(element) & &quot;'&quot;
			case &quot;lname&quot;
			sql=sql & &quot; and lname like '&quot; & Request.form(element) & &quot;%'&quot;
			case &quot;fname&quot;
			sql=sql & &quot; and fname like '&quot; & Request.form(element) & &quot;%'&quot;
			case &quot;init&quot;
			sql=sql & &quot; and init like '&quot; & Request.form(element) & &quot;%'&quot;
			case &quot;mobile&quot;
			sql=sql & &quot; and mobile like '&quot; & Request.form(element) & &quot;%'&quot;
          case &quot;dept&quot;
			sql=sql & &quot; and dept like '&quot; & Request.form(element) & &quot;%'&quot;

		end  select 
	end if
next
sql=sql & &quot; order by lname&quot;
'response.write sql'***debug
	rs.open sql,conn
	if rs.eof and rs.bof then
		response.write &quot;No Record Found&quot;
	else
		response.write &quot;<table width=550 border=0><th align=left>Last Name</th><th align=left>First Name</TH>&quot;
		response.write &quot;<th align=left>Tel</TH><th align=left>Mobile</TH><th align=left>Initials</TH><th align=left>Dept</TH>&quot;
		do while not rs.eof
		if flag=0 then
			flag=1
			color=&quot;#A5C3C3&quot;
		else
			flag=0
			color=&quot;#FFFFC0&quot;
		end if

		response.write &quot;<TR bgcolor=&quot;& color & &quot;><TD>&quot;
		response.write RS(&quot;lname&quot;) & &quot;</td><td>&quot; & RS(&quot;fname&quot;) & &quot;</td><td>&quot; 
		response.write RS(&quot;tel&quot;) & &quot;</td><td>&quot; & RS(&quot;mobile&quot;) & &quot;</td><td>&quot; & RS(&quot;init&quot;) & &quot;</td><td>&quot; 
		response.write RS(&quot;dept&quot;) & &quot;</tr></td>&quot;
		rs.movenext
		x=x+1
	loop
	
	response.write &quot;<tr><td colspan=7>Total Records : &quot; & x & &quot;</table>&quot;
	end if
end select
%>
<script>function rusure() { 

 if (confirm(&quot;Are you sure you want to delete?&quot;)) { 
return true; 
 } else { 

return false; 
 } 
} 
</script>

<head>

<style>
a:hover{color:red}
</style>
<title>Telephone Directory</title>
</head>

<body link=&quot;#000080&quot; vlink=&quot;#000080&quot; alink=&quot;#000080&quot;>

    <div align=&quot;center&quot;>
      <center>

	<table border=&quot;0&quot; width=&quot;450&quot; cellspacing=&quot;0&quot; cellpadding=&quot;3&quot; style=&quot;border:1px groove #B52100; border-collapse:collapse&quot; bordercolor=&quot;#111111&quot;>
<tr><td colspan=&quot;2&quot; align=&quot;center&quot;>
    <p align=&quot;center&quot;><img border=&quot;0&quot; src=&quot;IMAGES/main.png&quot;></tr>
<form action=&quot;search.asp?action=search&quot; method=&quot;post&quot;>
<tr><td colspan=&quot;2&quot; align=&quot;center&quot; bgcolor=&quot;#B52100&quot;><font face=&quot;Verdana&quot; color=&quot;#FFFFFF&quot; size=&quot;1&quot;> Clicking on
    <b> search</b> without choosing any category will retrieve all records</font></tr>
	<tr><td bgcolor=&quot;#C0C0C0&quot;>
        <font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
		Search by Last name:(A-Z)</font></td><td bgcolor=&quot;#C0C0C0&quot;>
      <font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;lname&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></font></tr>
	<tr><td bgcolor=&quot;#C0C0C0&quot;>
        <font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
		Search by First name:(A-Z)</font></td><td bgcolor=&quot;#C0C0C0&quot;>
      <font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;fname&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></font></tr>
	<tr><td bgcolor=&quot;#C0C0C0&quot;>
        <font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
		Search by Phone No .:</font></td><td bgcolor=&quot;#C0C0C0&quot;>
      <font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;tel&quot; size=&quot;10&quot; maxlength=&quot;5&quot;></font></tr>
		<tr><td bgcolor=&quot;#C0C0C0&quot;>
        <font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
		Search by Initials</font></td><td bgcolor=&quot;#C0C0C0&quot;>
          <font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;init&quot; size=&quot;5&quot; maxlength=&quot;5&quot;></font></tr>
   <tr><td bgcolor=&quot;#C0C0C0&quot;>
        <font face=&quot;Verdana&quot; size=&quot;2&quot; color=&quot;#B52100&quot;>
		Search by Department</font></td><td bgcolor=&quot;#C0C0C0&quot;>
     <font face=&quot;Verdana&quot; color=&quot;#B52100&quot;><input type=&quot;text&quot; name=&quot;dept&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></font></tr>

		<tr><td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot;>
            <table border=&quot;0&quot; width=&quot;100%&quot;>
              <tr>
                <td width=&quot;33%&quot;></td>
                <td width=&quot;33%&quot; style=&quot;border: 2px outset #B52100; &quot; align=&quot;center&quot;>
                  <p align=&quot;center&quot;><font face=&quot;Verdana&quot; size=&quot;2&quot;><a href=&quot;search.asp&quot; style=&quot;text-decoration:none&quot;>
                  <font color=&quot;#B52100&quot;>Clear</font></a></font></td>
                <td width=&quot;34%&quot;></td>
              </tr>
            </table>
          <td align=&quot;center&quot; bgcolor=&quot;#C0C0C0&quot;>
          <font face=&quot;Verdana&quot; color=&quot;#B52100&quot;>
          <input type=&quot;submit&quot; value=&quot;Search&quot; style=&quot;border:2px ridge #B52100; background-color: #C0C0C0; &quot;></font></tr>
		</table>
      </center>
    </div>
    <p align=&quot;center&quot;>
    </a></p>
</body>
 
dsn=&quot;CSOLPhone&quot;
You need to specify the username and password also in this string.

dsn=&quot;CSOLPhone,UID=youdbuserid,PWD=dbuserpassword&quot;
 
Thanks, I tried that but it did not work, there is no password in use on the database, it is in a folder that all authenticated users have read access to.
 
I always use
<!-- #include file=&quot;connect.inc&quot;-->
at the top of the script with this inside

<% gsConnect = &quot;Driver={Microsoft Access Driver (*.mdb)};DBQ=&quot; & Server.MapPath(&quot;yourdatabase.mdb&quot;)%>

Then
conn.open gsConnect

Hope it helps.


Gary
 
Thanks Gary, I am trying this method as an alternative to the DSNLess connection as I have been getting provider errors from this asp/db combo which require a server restart to fix. Not a good thing.
 
Try this:
dsn=&quot;DSN=CSOLPhone&quot;

instead of what you have:
dsn=&quot;CSOLPhone&quot;
 
Thanks but no, same problem - Admin Rights OK, User Rights Not.
 
i had this same problem. I dont understand it all but the server administrator had to do something with the IUser account.

g
 
What this ('800004005' [ODBC Driver Manager]Data Source name not found and no default driver specified) has always proven to mean in my experience is that either you didn't specify the DSN, or ADO couldn't find the DSN as you defined it (did you make sure it was on the server and named as you reference it? :).

Since it was (and perhaps still is) my opinion that the code that you posted did not correctly specify the connection string (identifying the DSN), I suggested (in effect) that you use:

conn.open &quot;DSN=CSOLPhone&quot;

but you say that doesn't work. I have never seen code that would cause a default driver to be used (as the text of the error message from ADO would indicate is possible), but perhaps it is possible, and perhaps that is somehow what is happening to you.

I don't quite understand what you mean when you say that the code will run with admin rights, and perhaps (if you are using SQL Server) this points out my lack of knowledge with how IIS and SQL Server can be made to use Challenge/Response to share user information SQL Server. So I would have assumed that your code will be running on the server as the IUSR_<machinename> (or perhaps the IWAM_<machinename> account). But what exactly do you mean when you say this? What account are you setting to have admin rights?

You say that &quot;Allow Anonymous&quot; is disabled, but perhaps you should make sure that either &quot;Basic&quot; or &quot;Challenge/Response&quot; is enabled (if your users are all using IE, use CR; otherwise use Basic).

All this aside - and assuming that the syntax for your connection string is incorrect (i.e. it doesn't have the &quot;DSN=&quot; part), it still doesn't make sense to me how ADO knows which database to try to connect to.

I hope I have at least given you something to think about!

Please let us know what you find out.
 
Ok here's the latest incarnation of the code with the connection as above

Code:
dim dsn,conn,rs,sql,x
dim flag,color,useraction,element
useraction=request.querystring(&quot;action&quot;)
select case useraction
case &quot;search&quot;
	x = 0
	sql = &quot;select * from users where id>0&quot;
	set conn = server.createObject(&quot;adodb.connection&quot;)
	set rs = server.createObject(&quot;adodb.recordset&quot;)
	conn.open &quot;DSN=CSOLPhone&quot;

The server is in an NT Authenticated domain and uses challenge/response for access to all resources.

When I talk of Admin rights if I use my account via the web browser that has domain administrator rights to the machine then the code above runs correctly, however if I use an account with user level rights then it does not but the dsnless version below does.

Code:
dim dsn,conn,rs,sql,x
dim flag,color,useraction,element
useraction=request.querystring(&quot;action&quot;)
select case useraction
case &quot;search&quot;
	x = 0
	sql = &quot;select * from users where id>0&quot;
	set conn = server.createObject(&quot;adodb.connection&quot;)
	set rs = server.createObject(&quot;adodb.recordset&quot;)
	dsn=&quot;DBQ=&quot; & Server.Mappath(&quot;db/mydb.mdb&quot;) & &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;
	conn.open dsn

This indicates that the rights to the resources (asp pages, database etc) are correct.

So somewhere down the line the user does not have rights to the DSN, or something.

Today is the last day for 2 weeks I will be able to address this as I have a nice course in Uxbridge next week and holiday the week after that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top