VSSDatabase.Open via ASP.NET

A customer recently sent me the following code, which uses VSS automation to open a SourceSafe database via an ASP.NET page.  He was running IIS locally against a remote VSS server and, upon running the code got the following error message: ”The SourceSafe database path Guest does not exist. Please select another database.”

<%@ Import Namespace="SourceSafeTypeLib" %>
<html>
 
<head>
   
<title>Testing VSS Automation with ASP.NET</title></head>
 
<body>
   
<script language="C#" runat=server>

VSSDatabase db = new VSSDatabase();

void Page_Init (Object oSender, EventArgs oEvent)
 {
 
string path = @\\vsufile\vsstest\srcsafe.ini;
  string user = "Admin";
 
string pass = "*pass!1wor2t";
 
db.Open(path, user, pass);
 }

   
</script>
  </body>
</html>

Issue Description and Workaround
This error message appears when VSS is unable to locate or gain access to a srcsafe.ini file.  To work around this issue, one must grant permission to the ASPNET user for the \\vsufile share or allow IIS impersonation on the Web server.
The appearance of "Guest" in the error message is a known issue. Apparently, the 'user' and 'path' variables got transposed in the code.

This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft kann für die Richtigkeit und Vollständigkeit der Inhalte in dieser Newsgroup keine Haftung übernehmen. Este mensaje se proporciona "como está" sin garantías de ninguna clase, y no otorga ningún derecho.

Published 24 June 03 06:40 by KorbyP

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# JB said on October 15, 2003 5:03 PM:
I'm doing the same thing, and seeing the same error message. However I don't think it's a permission issue with srcsafe.ini -- elsewhere in the code, I'm able to open the srcsafe.ini (with StreamReader) and read the first line from it. So the app certainly has permission to access the file.
# Ville said on October 30, 2003 7:18 AM:
I'm having the exact the same problem.... Please tell me if you solve the problem..
# TK said on March 2, 2004 11:57 AM:
I'm having the exact same problem, not a permission issue... Please let me know what the solution is... Thanks...
# VSS COM+ extensions lack-luster said on May 4, 2004 2:29 PM:
Using the sourcesafetypelib via COM Interop in .NET don't seem to work all that great. try mixing up the order of the 3 parameters of the VSSDatabase.Open method. If you do it right, it says can't find database <user>, if you put the <user> and <password> first it says it doesn't have access, if you put the <user>, <ini file>, then <password> you get a "Cannont open <ini file> error. The error messages you see just don't make any sense at all. I've heard there might be a bug in the way they are transposed, but me don't no nothing about no "transposing". No just know "noworkie". Oh well, I guess that's what VB6 is for, huh.
# Shawn Anderson said on June 18, 2004 10:46 AM:
Has anyone found a solution to this issue? I am fighting with it aswell :-/
# Art said on June 21, 2004 11:41 AM:
I think it is a permission issue. Run this code below as an ASP.NET page and then a Console application.
--------------
using SourceSafeTypeLib;

VSSDatabaseClass objVSSDB = new VSSDatabaseClasss();
objVSSDB.Open("PathToSRCSAFE", "validUser", "validPass");
--------------

Personally when run as Console app I had no problems connecting to VSS but if run as an ASP.NET app I failed w/ an error saying that "validUser in not a valid user ... please use different database"
# Art said on June 21, 2004 12:13 PM:
One more observation. When I run previously presented code as an ASP.NET application on the web server where the VSS server was located I successfuly connected and retrieved files from VSS. So, IIS and VSS servers have to be on the same machine for things to work. BYW, I have also added ASPNET account to these who can access and modify VSS directory where srcsafe.ini is included.
# Rob Gallo said on June 25, 2004 2:47 PM:
I believe that I have found one somewhat insecure way around this. By default the ASPNET_WP runs under the ASPNET user which is more restricted then running as a system account. If you modify your machine.config file, and set the processModel in the
<System.Web>
<processModel />
to use either SYSTEM or a domain account, this problem goes away, and no further changes are required to the locations where the vss files are stored.
# Jesse said on July 12, 2004 12:37 PM:
this may be the stupid way, but try declaring the database as an IVSSDatabase, a la:

SourceSafeTypeLib.IVSSDatabase db2 = new VSSDatabaseClass();
db2.Open(@"\\path\srcsafe.ini", "username","pass");

that seems to work for me, at least
# longmain said on July 6, 2005 12:21 AM:
this may be the stupid way, but try declaring the database as an IVSSDatabase, a la:

SourceSafeTypeLib.IVSSDatabase db2 = new VSSDatabaseClass();
db2.Open(@"\\path\srcsafe.ini", "username","pass");

that seems to work for me, at least
============================================

I am writing ASP.NET in VB.net, I failed to find New() method for neither IVSSDatabase nor IVSSDatabaseOld. I have no idea how Jesse get it work.

I also try to get the srcsafe.ini file to local machine and change the "The two important paths used by SourceSafe" -- Data_Path & Temp_Path to point to the server's path with \\server\vss\..(etc.). And I modified the Users_Txt option of the local-copied srcsafe.ini. Then I try to point to the local-copied srcsafe.ini file. I got the following error message:"
System.Runtime.InteropServices.COMException: Visual SourceSafe database \\server\vss\data does not exist. Please select another database.”

I am still tring. If anybody have development, tell me :(
longmain@hotmail.com

# JE said on August 30, 2005 5:52 PM:
If you're doing this like I was, you were attempting to use the VSS com object via com interop. With impersonation on (in web.config), I could:

1) Read/write files on my web server from my code. (No problem)
2) with impersonation/delegation, read/write files on a file share from my code.
3) Have the VSS COM object manipulate a VSS database on my web server.
What I could not do, was
4) Have the VSS COM object manipulate a VSS database on some file share.

Impersonation was NOT extended to the COM object. It worked in my code, though. From looking at security logs, it looks like the vss object was trying to log in as IUSR or some account local to the web server -- not a domain account, and definitely not my impersonated account.

I found a solution here:
http://www.dmbcllc.com/server.aspx
I don't know how it works, but apparently if you create a com+ application on your web server, you can give it any domain login you like, and that login will be impersonated/delegated to any VSS server. This fits my requirement ok for now.

-J
# Boler Guo said on October 9, 2005 4:09 AM:
http://www.siteexperts.com/forums/viewConverse.asp?d_id=15214&Sort=0

i try this:
<identity impersonate=true userName=Domainname\networkuserlogin password=trustme />

but no use~
# Boler Guo said on October 9, 2005 4:10 AM:
http://www.siteexperts.com/forums/viewConverse.asp?d_id=15214&Sort=0

i try this:
<identity impersonate=true userName=Domainname\networkuserlogin password=trustme />

but no use~
# MR T. said on April 5, 2006 2:02 PM:
I used the following:

string path = "c:\website\vss\srcsafe.ini";

that being the location on the server that the aspx pages are loaded, then in that srcsafe.ini file i had the following

#include \\server\share\srcsafe.ini

that worked a treat for me.
# Andy said on June 22, 2006 6:25 PM:
I tried the #include suggested... I don't know if I goofed something up, but it did not work.
# health insurance international said on August 25, 2006 9:25 AM:
Very informative post about <a href="http://approvalcredit.bravehost.com/health-insurance-international.html"">http://approvalcredit.bravehost.com/health-insurance-international.html" title="health insurance international">health insurance international</a> and [URL=http://approvalcredit.bravehost.com/health-insurance-international.html]health insurance international[/URL]
# Pol Pitt said on August 26, 2006 11:58 PM:
I am so lucky on [url=http://2access.2surf.eu]having[/url] what I have! And good luck in yours [url=http://access.122mb.com]search[/url].
Just visit [url=http://access.2surf.eu]my site[/url].








# instant insurance life quote said on August 31, 2006 9:30 AM:
Very interesting and good point about <a href="http://freeinsurance.250free.com/instant-insurance-life-quote.html"">http://freeinsurance.250free.com/instant-insurance-life-quote.html" title="instant insurance life quote">instant insurance life quote</a> and [URL=http://freeinsurance.250free.com/instant-insurance-life-quote.html]instant insurance life quote[/URL]
# play card games online said on September 6, 2006 5:51 PM:
Thank you so much for this great post  about <a href="http://freecarhire.bravehost.com/play-card-games-online.html"">http://freecarhire.bravehost.com/play-card-games-online.html" title="play card games online">play card games online</a> and [URL=http://freecarhire.bravehost.com/play-card-games-online.html]play card games online[/URL]
# bad credit unsecured loan said on September 7, 2006 10:02 PM:
Very informative post about <a href="http://debtoff.50megs.com/bad-credit-unsecured-loan.html"">http://debtoff.50megs.com/bad-credit-unsecured-loan.html" title="bad credit unsecured loan">bad credit unsecured loan</a> and [URL=http://debtoff.50megs.com/bad-credit-unsecured-loan.html]bad credit unsecured loan[/URL]
# Poll Pitt said on September 16, 2006 8:41 AM:
I am so [url=http://access.2surf.eu]lucky[/url] on having what I have! And good luck in yours [url=http://2access.2surf.eu]search[/url].
Just visit [url=http://access.122mb.com]my site[/url].









# Sourcesafe Automation Bug &laquo; BuLOnG said on April 14, 2008 1:26 AM:

PingBack from http://superpatrick.wordpress.com/2008/04/14/sourcesafe-automation-bug/

Leave a Comment

(required) 
(optional)
(required) 

Search

Go

This Blog

Syndication

Page view tracker