.NET Framework - access folder at another computer with automatic Windows authentication

Asked By Andrius B.
18-Jan-08 09:27 AM
Hi.
I am writing an app, whitch has to access a database, located on another
computer (Intranet).
Let's say, the computer where the app is to be installed, is "Computer1".
The computer with the database is "Computer2", and the full path to needed
database is "\\Computer2\AppFolder\mydata.mdb".
The user can access that folder when it authenticates as "user1" with
password "password1".
Question: how to automate the connection, making it possible to log to the
computer2 automaticaly at run time programically?
By default, the app, without authenticating,  cannot open that database, so
it shows FileOpen dialog for browsing to the desired computer, then to the
shared folder, at this step the input form appears, asking to enter username
and password; the app's user enters them, and succesfully enters the folder
and selects the database, and the connenction is performed.
So, could this be done faster, eg. writing some parameters to the database's
connection string, o using IO.System objects or so on?
The code below describes the connection to db:

' Start of code
Dim sConnSample = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
ADODBconn = New ADODB.Connection
ADODBconn.Mode = ADODB.ConnectModeEnum.adModeReadWrite
ADODBconn.Open(sConnSample)
' End of code

So, should I add some parameters to cConnSample, like "UserId" ?


Thanks in advance.
ADODB.Connection
(1)
Windows XP
(1)
ADODBconn
(1)
ADODB
(1)
Visual
(1)
Map
(1)
Database
(1)
CConnSample
(1)
  Andrius B. replied...
18-Jan-08 09:32 AM
By the way, the installed OS on both computers are Windows XP.
I use Visual Basic 2005.
  Shuja Ali Zaroo replied...
18-Jan-08 01:40 PM
Hi Andrius,
You will need to MAP the network drive using network credentials and then
you can access the database.  One way of setting up a Map drive would be to
use Process.Start along with NET USE Dos command.

Shuja
Create New Account
help
Anmeldescript VBS .NET Framework Hallo, in unserer Umgebung (Windows Terminalserver 2003 + Windows Server 2003 + Windows XP Client) haben wir ein An- und Abmeldescript (VBS) , welches ?ber die Gruppenrichtlinie unter "An- Abmeldeskript einem Skript wie dieses gel?st werden kann ? Danke MfG Albe Scripting WSH - German Discussions ADODB.Connection (1) Windows XP (1) Windows Server 2003 (1) Scripting.FileSystemObject (1) WScript.Shell (1) CreateNewMDB (1) Connect2WSUS (1
mit der url z.B: 'http: / / www.testserver.pytalhost.com' pytalhost ist kostenloser Webspace (kein Windows-server). Wie kann ich ich jetzt auf die DB zugreifen? Habe folgendes probiert: ' Connection-Objekt Dim oConn As ADODB.Connection ' Instanzierung des Objekts Set oConn = New ADODB.Connection ' Recordset-Objekt Dim oRS As Recordset ' Recordset erstellen Set oRS = New ADODB.Recordset ' ?ffnen With es kommen nur Fehler. Kann die DB nicht ?ffnen. Ich arbeite noch mit VB6 und Windows XP. Framework 3.5 ist installiert. Im VB-Projekt ist Microsoft ActiveX Data Objects 2.8 Library aktiviert. Vielen Dank VB DataBase - German Discussions ADODB.Connection (1) MySQL (1) ADODB.Recordset (1) Windows XP (1) Linux (1) ADODB (1) IIS
E4dt) auf = unseren SQL 2005 Server = FCber den SQL Server Native Client zu. = 20 Unter Windows 2000 und XP funktioniert das Programm wunderbar. Jetzt habe ich eine Vista-Arbeitsstation und wenn ich auf dieser in der ein Datenzugriff stattfindet. = 20 Anbei ein Ausschnitt aus dem Quellcode: * ** ** ** ** ** ** ** ** ** ** ** * Dim Con As ADODB.Connection 'Connection zum SQL-Server Set Con = 3D New ADODB.Connection With Con .Provider = 3D "SQLNCLI.1" .Properties("Data Source") = 3D "server" .Properties("Integrated Security") = 3D End Else MsgBox rs!version & vbCr & vbCr & " TEST!", vbInformation, "TEST" End If End * ** ** ** ** ** ** ** ** ** ** ** * Auf der XP-Arbeitsstation bringt er die erste Message-Box mit der Anzahl = der Datens = E4tze, dann 'TEST Dank im Voraus! Mit freundlichen Gr = FC = DFen = 20 Stefan Voit VB DataBase - German Discussions ADODB.Connection (1) SQL Server 2005 (1) ADODB.Recordset (1) Active Directory (1) Vista (1) ADODB
Does anybody have any idea what might be going on here?! Thanks, Dan WSH Discussions ADODB.Connection (1) SQL Server (1) Windows XP (1) Windows Server 2003 (1) WScript.CreateObject (1) Vista (1) WScript.Arguments (1) WScript.Shell (1) I it perhaps a 16-bit application? If so, it won't run under 64-bit Windows. - - Michael Bednarek http: / / mbednarek.com / "POST NO BILLS" Hi everyone, Thank you all for your cmd prompt on the 64-bit workstation just now and here is the output. . . . . . - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - Microsoft Windows [Version 5.2.3790] (C) Copyright 1985-2003 Microsoft Corp. C: \ Documents and Settings \ dhnash l \ Policies \ {31B2F340-016D-11D2-945F-00C04FB984F9} \ USER \ Scripts \ Logon \ MM_logon.vb s Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. \ boris
wie gewünscht. Die Connection stelle ich wie folgt her: strTmpPfad = Environ$("Tmp") Set cnnTxt = New ADODB.Connection cnnTxt.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & strTmpPfad & ";Extendet Properties = ""text;HDR don't remove Bugs, they only show them in Slow-Motion. VB DataBase - German Discussions ADODB.Connection (1) Windows XP (1) Vista (1) ADODB (1) ColNameHeader (1) MaxScanRows (1) CharacterSet (1) StrTmpPfad (1) *Reiner Wolff