LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Windows Service App tries to create a file using the currently logged user account instead of the account under which the service is running.

Hi there:

This is my very first post on the forums so I'am not sure if I'am posting on the right board. Anyhow, I do know that I need HELP!

I have created a Server App and set it to run as a Windows Service (using srvany.exe).

The Server App is intended to manage files under a Results Directory that has full access permissions for the Account under which the Windows Service
runs but has limited (READ\EXECUTE) permissions to members of the Users group.

There is a Client App that wil be running under a regular User account that must gather data and write it to files that will be stored inside the
Results Directory. However, the files cannot be modified (Created\Written\Appended) by the account under which the Client App is running. Hence, I need the Server App to write the files for the client, since the server is running under an account that (supposedly) has the necessary privileges.

The problem is that when my Client App sends the data to the Server App, the Server App tries to create the files as if running under the
limited User account. Because the limited User account CANNOT create files in the Results Directory, I get a File Permissions Error (error 8).

I don't get any errors when I run the Server App (as a Windows Service) under an account and run the Client App under another account that has 
permission to create files under the Results Directory. However, the owner of the file that is created is the account under which the Client App is running
and not the account under which the Server App is running (who is the one that CREATED the file and should be the owner).

I'am using the VI Server to run the Server App with the following options in the .INI file:

[My Server]
server.tcp.enabled=True
server.tcp.access="+*"
server.tcp.port=3363
runAsService=TRUE

The Client App communicates with the Server App using the Open Vi Rerence with a strict type reference and the Call by Referece Node.

Any help will be greatly appreciated,

Elliot Vargas



0 Kudos
Message 1 of 4
(2,827 Views)

Elliot buen día,

 

No es tan trivial el asunto que manejas por lo que hemos estado revisando la información que nos proporcionaste y muy pronto tendrás noticias, que tengas un buen día!

 

Gracias por usar los Foros de National Instruments!

 

NorSa

NI Applications Engineer Latin America

NorSa
(Former) NI Applications Engineer Latin America
0 Kudos
Message 2 of 4
(2,755 Views)
Saludos NorSa:

No habia vuelto ha escribir sobre el problema debido a que habia implementado el servidor y el cliente
usando los VIs de TCP y esto sí funciono como un servicio de Windows. Debido a que encontre una solución
al problema, y tenia mucho trabajo, pues ya me habia olvidado de que habia expuesto mi problema aqui.

De todas formas, gracias por contestar pues me diste la oportunidad de exponer lo que creo que ocasiona el
problema.

Yo creo que el problema esta en la forma en que los VIs son traidos a memoria en el lado del servidor.
En el tutorial que yo segui (http://zone.ni.com/devzone/cda/tut/p/id/3185#toc2) se explica que para
traer a memoria VIs sin tener que ejecutarlos bastaba con poner todos los VIs dentro de la opción de
cierto (true) en un bloque condicional y conectarle una variable falsa al bloque.

Sin embargo, el otro dia abrí con LV 8.2 unos VIs hechos en LV 7.x y cuando LV hizo la conversion
automatica de los VIs me dio una advertencia que decia que esta manera de traer VIs a memoria (usando
el "truco" del bloque condicional) no estaba apoyada desde LV 8.0, y que ahora habia que utilizar los
metodos del VI Server.

Si éste es el problema, pues significa que los VIs no estan en memoria al momento en que el servicio de
Windows se lanza. Sino que los VIs son traidos a memoria la primera vez que se llama un método en el servidor.
Esto puede explicar porqué el metodo se ejecuta en espacio de usuario, y por tanto los archivos pertenecen a la
cuenta bajo la cual se ejecuta el cliente.

No he probado la alternativa de traer los VIs a memoria en el lado del servidor usando los VIs de VI Server. Seria
una buena alternativa a tratar.
0 Kudos
Message 3 of 4
(2,742 Views)

Elliot buen día!

En lugar de llamar el ServerApp del Client App usando el "Open Vi Reference with a strict type reference and the Call by Reference Node", podrías usar "Open Vi Reference" junto con el nodo property/invoke para pasar datos al ServerApp (no llamar por Reference Node with Strict Type)

Hay una liga que te puede ayudar a ver este ejemplo:

http://zone.ni.com/devzone/cda/epd/p/id/4475

Espero que también te pueda servir. Te mando un gran saludo y gracias por usar los Foros de National Instruments!

 

NorSa

NI Applications Engineer Latin America

NorSa
(Former) NI Applications Engineer Latin America
0 Kudos
Message 4 of 4
(2,727 Views)