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.”


size=2><%@ Import Namespace=”SourceSafeTypeLib” %>
style="FONT-SIZE: 12pt"> size=2><html>
 
face=Arial color=#0000ff size=2><head>
   
size=2><title>Testing VSS Automation with
ASP.NET</title></head>
 
style="FONT-SIZE: 12pt"> size=2><body>
   
style="FONT-SIZE: 12pt"><script
language=”C#” runat=server>

style="FONT-SIZE: 12pt">VSSDatabase db =
new VSSDatabase();

face=Arial color=#0000ff size=2>void Page_Init (Object oSender, EventArgs
oEvent)
color=#0000ff size=2> {
 
style="FONT-SIZE: 12pt">string path = @ href="file://\\vsufile\vsstest\srcsafe.ini">\\vsufile\vsstest\srcsafe.ini;
style="FONT-SIZE: 12pt">  string user
= “Admin”;
 
face=Arial color=#0000ff size=2>string pass = “*pass!1wor2t”;
 
size=2>db.Open(path, user, pass);
style="FONT-SIZE: 12pt"> size=2> }

   
style="FONT-SIZE: 12pt"> size=2></script>
face=Arial color=#0000ff size=2>  </body>
style="FONT-SIZE: 12pt"> size=2></html>
face=Arial color=#0000ff size=2>
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.
style="FONT-SIZE: 12pt">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.

Comments (24)

  1. JB says:

    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.

  2. Ville says:

    I’m having the exact the same problem…. Please tell me if you solve the problem..

  3. TK says:

    I’m having the exact same problem, not a permission issue… Please let me know what the solution is… Thanks…

  4. 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.

  5. Shawn Anderson says:

    Has anyone found a solution to this issue? I am fighting with it aswell :-/

  6. Art says:

    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"

  7. Art says:

    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.

  8. Rob Gallo says:

    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.

  9. Jesse says:

    this may be the stupid way, but try declaring the database as an IVSSDatabase, a la:

    SourceSafeTypeLib.IVSSDatabase db2 = new VSSDatabaseClass();

    db2.Open(@"\pathsrcsafe.ini", "username","pass");

    that seems to work for me, at least

  10. longmain says:

    this may be the stupid way, but try declaring the database as an IVSSDatabase, a la:

    SourceSafeTypeLib.IVSSDatabase db2 = new VSSDatabaseClass();

    db2.Open(@"\pathsrcsafe.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 \servervss..(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 \servervssdata does not exist. Please select another database.”

    I am still tring. If anybody have development, tell me 🙁

    longmain@hotmail.com

  11. JE says:

    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

  12. Boler Guo says:

    http://www.siteexperts.com/forums/viewConverse.asp?d_id=15214&Sort=0

    i try this:

    <identity impersonate=true userName=Domainnamenetworkuserlogin password=trustme />

    but no use~

  13. Boler Guo says:

    http://www.siteexperts.com/forums/viewConverse.asp?d_id=15214&Sort=0

    i try this:

    <identity impersonate=true userName=Domainnamenetworkuserlogin password=trustme />

    but no use~

  14. MR T. says:

    I used the following:

    string path = "c:websitevsssrcsafe.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 \serversharesrcsafe.ini

    that worked a treat for me.

  15. Andy says:

    I tried the #include suggested… I don’t know if I goofed something up, but it did not work.

  16. Pol Pitt says:

    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].

  17. 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]

  18. 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]

  19. 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]

  20. Poll Pitt says:

    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].