Connecting to network share

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Asprisa
    New Member
    • Oct 2007
    • 30

    Connecting to network share

    hi guys,

    i was wondering if there is a way to connect to a server share that requires a username and password without mapping it as a drive, what i wish to do is open a session so i can save a log file, but i do not wish the user who is running the application to see the share or the log file, i ahve played with an oledb connection but it kept complaining about workgroup information being missing.

    Here is my code:
    Code:
       
    '''insert some kind of connection string here
     
    Dim writer As New StreamWriter("" & fileloc & "" & nbkname & ".txt", True)
    writer.WriteLine("" & tmpuser & " Opened Drive Mapper at " & dateTimeInfo & "")
    writer.Close()
     
    '''close the connection
    the first line (just so you know what the code is doing) is saving to a file in a location set by the varaible fileloc and filename 'nbkname' .txt

    if anyone can help it would be much appriciated!

    Jay!
    Last edited by DrBunchman; Jul 3 '08, 12:20 PM. Reason: Added code tags - Please use the # button
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi there,

    Could you not give the username that your application is running under permission to access this share? That way the user would not be able to access the share but your application could.

    Dr B

    Comment

    • Asprisa
      New Member
      • Oct 2007
      • 30

      #3
      im not sure if this is possible as it will be run locally on around 128 notebooks, i want to obvisouly make as little work as possible for myself and anyone else who works on this project in the future. Is this possible the way you talk about?

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        Is this a website or windows app you're talking about?

        Comment

        • Asprisa
          New Member
          • Oct 2007
          • 30

          #5
          Sorry it is a windows app

          Comment

          • Asprisa
            New Member
            • Oct 2007
            • 30

            #6
            i just came across this code i will try this and let you know what happens.

            Code:
             Dim imp As New RunAs_Impersonator 
            Try
            imp.ImpersonateStart(DomainName, UserName, Password) 'creates new context using token for user
             
            Add code to run as UserName here 'everything between ImpersonateStart and ImpersonateStop will be run as the impersonated user
             
            imp.ImpersonateStop() 
            Catch ex As Exception 'make sure impersonation is stopped whether code succeeds or not
            MsgBox(ex.Message)
            imp.ImpersonateStop()
            End Try
            Jay!
            Last edited by DrBunchman; Jul 3 '08, 12:19 PM. Reason: Added code tags - Please use the # button

            Comment

            Working...