PDA

View Full Version : win2003server: problem with user permission



mattia
12th February 2008, 10:38
Hello, i compiled my app and i installed it under win2003server as admin.
If i run my app as admin i've not problem, but if i run it as simple user i can't create directories and files, i have no this permission.

The directory path, where to save data, are saved with QSetting in some keys, for example, they are in:

HKEY_CURRENT_USER->Software->myapp
keyname: path
keyvalue: C:\Documents and settings\admin\myapp

this for admin user.
Now, i switch user and i try with a simple user, the key "path" is always in the same place with the same value..., so when i lunch my app and i try to write a directory on filesystem i get an error, but a normal user can't write in "C:\Documents and settings\admin\myapp" 'cause , he/she has not the permission.

I hope i've been clear ;)
What should i do to fix it?
thx

edit
-------------------------------
to retrieve the path where to save data i use:
QDir::home ().absolutePath()

marcel
12th February 2008, 14:29
Now, i switch user and i try with a simple user, the key "path" is always in the same place with the same value..., so when i lunch my app and i try to write a directory on filesystem i get an error, but a normal user can't write in "C:\Documents and settings\admin\myapp" 'cause , he/she has not the permission.

When running as a regular user you must write to "C:\Documents and settings\username\myapp". Of course you can't access the admin home folder as a regular user. Can you access the root directory on linux as a regular user?

mattia
12th February 2008, 14:47
i know that...i was asking about a solution for that problem, my question is:
how to read the correct path (C:\Documents and settings\currentUser\myapp) if i installed the app like admin but i run it as normal user?
Is there a way to write in C:\Documents and settings\currentUser\myapp ?

bender86
12th February 2008, 15:26
You can use QDir::home() or QDir::homePath().

mattia
12th February 2008, 16:18
I've already tried with homePath() but it's the same...

marcel
12th February 2008, 16:49
What does homePath returns then?

przemoc
12th February 2008, 17:38
my question is:
how to read the correct path (C:\Documents and settings\currentUser\myapp) if i installed the app like admin but i run it as normal user?
Is there a way to write in C:\Documents and settings\currentUser\myapp ?
I'm not sure if any program can write in user's "home" directory in W2K3. Applications shoud use rather %APPDATA% directory. Look at my post:
Re: How to find Application Data directory? (http://www.qtcentre.org/forum/f-qt-programming-2/t-how-to-find-application-data-directory-10025.html#post62542)
Also check whether your non-admin user has rights to write in his directory.

bender86
12th February 2008, 19:48
I've already tried with homePath() but it's the same...
Do you mean that if you call homePath() as user someuser it returns C:\Documents and settings\Administrator? From its documentation (http://doc.trolltech.com/4.3/qdir.html#homePath) this is not possibile. Check if %USERPROFILE% env variable points to right directory.

@przemoc
Many applications (including designer and assistant) use %USERPROFILE%\.appname directory to store data, so I believe it is writable.

marcel
12th February 2008, 19:56
On Vista everything is OK. The correct user directory is returned.
Make sure you don't have any mistakes in your code.

mattia
13th February 2008, 13:23
I double-checked my code and it was a my mystake, if i use homePath() i can retreive the right path.
thx