Solved

write file with alternate credentials with visual basic .net

Posted on 2013-02-06
6
1,343 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
Comment Utility
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
Comment Utility
I just noticed you use a shared location...
0
 

Author Comment

by:chadmanvb
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:chadmanvb
Comment Utility
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
Comment Utility
0
 
LVL 25

Expert Comment

by:SStory
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now