Solved

write file with alternate credentials with visual basic .net

Posted on 2013-02-06
6
1,372 Views
Last Modified: 2013-02-06
I need to write log files, but the normal user does not have rights to this share.  Currently I call a console program under admin credentials to write the log files.  Is there a way I can just do that within my application?
0
Comment
Question by:chadmanvb
6 Comments
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 38859173
Hi

Do you use a setup for installing your application?
You could use one if you don't and have it change permissions to a specific folder where you are writing your logs. After all the setup will take place by an administrator who may run the installation as an administrator.

Giannis
0
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 38859179
I just noticed you use a shared location...
0
 

Author Comment

by:chadmanvb
ID: 38859215
Yep, it uses a file share on NAS.  My current console program is doing this fine, but I would prefer to not have to call another application to write the logs.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:chadmanvb
ID: 38859235
Here is how I call the console app, I was just hopping I could just write files within my appliction with the other user id.  It would also let me test that the log really got written to.  
  'write log file and add to user favorites
        Try


            Using SecurePassword As New System.Security.SecureString()

                For Each c As Char In strAccountPassword
                    SecurePassword.AppendChar(c)
                Next
                Dim WriteLog As New Process
                With WriteLog.StartInfo
                    .UseShellExecute = True
                    .UserName = "testid"
                    .Domain = "mydomain"
                    .Password = SecurePassword
                    .CreateNoWindow = True
                    .UseShellExecute = False
                    .Arguments = strAppUser & " " & strCommand
                    .FileName = "C:\Program Files\RemoteDeskTop\EasysysUsageLog.exe"
                End With

                WriteLog.Start()

            End Using



        Catch ex As Exception

            'error log failed to write
        End Try
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38859602
0
 
LVL 25

Expert Comment

by:SStory
ID: 38859608
Well, if this is Windows 7 and the issue it getting to write in "Admin" mode, you might consider a Windows service--I suppose. In that service it would have the rights or the user could set the service to run as administrator.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question