How to build a C# application and installer that uses SQL Server LocalDB to be accesible to all users on same PC without prompt by UAC? - sql-server

My app runs normally under Windows Administrator account there is no problem.
Except that when run under Guest Account, it has to be run as administrator for the DB to be accessible, or else I'll get an error
Failed to update .mdf database because the database is read-only
So UAC always pops up if Guest account wants the app to work.
The purpose of the app is for everyone, but whenever a guest user runs it, an admin has to run over and enter his password into UAC -- that is going to wear out the patience of everyone, don't you think? What I need (and in my opinion, logical) is for it to run as admin automatically once installed (admin installs it anyway). Or at least, an admin need enter password on UAC only once, not every time.
Is this really not easily available?

Set the permissions on the database files:
MyDatabase.mdf
MyDatabase_log.ldf
So that Everyone has Full Control.

Related

What user does SSMS database creation run under?

I have a (S:\) drive with permissions for only myself and the SYSTEM user.
I just downloaded SQL SERVER EXPRESS 2017, and when I go to create a new database, it cannot see that drive as a place to create the database.
I tried giving the Everyone group full permissions on the drive, and then it showed up as a place to make the new database.
I am wondering what user I need to actually give permissions too, as it is clearly not running under my user, since my user has full control on the drive, and it's not running as SYSTEM, since that user has full control of the drive. I don't want to give "Everyone" permissions to the drive.
Note: Doing a bit more experiments, after removing the Everyone permissions, I went looking through my users list (in the Security tab of the Drive properties), and the only user that looks to have anything to do with SQL is SQLServer2005SQLBrowserUser${myUserName}, but giving this user full control did not allow SSMS to see the drive again.
Run this query:
SELECT * FROM sys.dm_server_services
And you will see current available services on your SQL Server instance and the account mapped to each one. Add permissions to the one that's below the servicename: SQL Server (MSSQLSERVER), it will be most likely NT Service\MSSQLSERVER.
If you use Jobs on the Agent, you will need to give permissions to that account also.

Is there any way to protect PostgreSQL access via pgAdmin when an intruder changes pg_hba.conf file?

I have a password protected PostgreSQL database (running on windows) which has been accessed by an unauthorized person several times using this simple trick as described here:
Stopping PostgreSQL Windows service
Changing md5 to trust in pg_hba.conf file
Starting Windows service
Accessing database via pgAdmin without a need of password
Is there any way to block this mechanism? I've been thinking about multiple windows users (there's only one administrator account on the machine right now) with limited file change privileges, but I am worried about database functionality and I would prefer a little bit more straight-forward solution.
UPDATE
Thank you all for your responses, they were all very helpful.
It's obvious to me now the user accounts are the way - probably the only right way at all.
Indeed the way to solve the problem is not by looking into PostgreSQL, but by looking into your Windows security. Once someone gains administrator privileges, there is nothing which stops the person from changing anything - this includes your PostgreSQL settings. Even if you set a database password and set proper permissions for the pg_hba.conf file, the unauthorized person can still change the permissions back, or start the database in single user mode (no password required) and modify the passwords.
Create separate Windows user accounts, protect the Admin with a password, and stop using the Admin account for day-to-day work.
Perhaps change all your users to limited. Create a user called postgres thats also limited and set it so that that its the only user that can read/write its own files. You will have your administrator account, that still can do whatever you want to do. Now run the postgres service as the user postgres and youre done.
... and stop giving people your admin password -- you should be fine ;)

Can't see the Site Settings option for SSRS 2012

I don't seem to have the Site settings option on my SSRS instance.
I have looked at numerous online suggestions including:
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/bc47050a-a733-4a27-a55a-64159453d83e
When I try to access the report server url using IE as Run As Administrator, I get a login box everytime.
From reading numerous articles it sounds like I need to the System Administrator in SSRS to view the option but have no idea how to add a user to this system role. I have so far created New Role using Folder --> Settings for the everyone group and that has at least given me access to the reports and let me publish reports etc.
Other than reinstalling SSRS, any suggestions?
It sounds like you're folder/object level permission; you need to set the site permissions, too.
To do this you'll need to log in as a server administrator; by default only the BUILTIN\Administrators group have the System Administrator role in a Report Server.
Once you have logged into Report Manager as a server administrator, click on Site Settings -> Security and add whatever groups/users required:
See Granting Permissions on a Report Server.
At the site level, on the Site Settings page in Report Manager, create
a system-level role assignment for each user and group using the
predefined roles System User and System Administrator.
If you have UAC enabled you will need to run IE with Run As Administrator; if IE is prompting you for credentials you can suppress this by making sure User Authentication is set correctly in Internet Options -> Security Settings; set it to something like Automatic logon with current user name and password.
If u don't find site settings option ie home page displays only home,subscription & help,then u run IE as administrator .Go to internet options,tools,security,custom levels,under user authentication
make automatic login user & password yes
- restart the pc
u'll get the site settings,folder settings tab

Not able to shutdown Oracle Database ORA-01031

I am having trouble shutting down a local oracle database. I've googled the problem, and the SYSTEM user I am using is in the ora_dba domain, and I also noticed that I need the sqlnet.ora in my ORACLE_HOME/network/admin folder, but I do not have a network/admin folder in my oracle home. All I have is a middleware folder. I am installing all of this to be able to publish a BPEL process to a local weblogic instance, and this has taken me a little over two days just trying to get this all set up. I am starting to get a bit frustrated lol. Here's the error I am getting below:
In order to startup/shutdown the oracle instance you need extended privileges - Oracle database SYS privileges.
As soon as your Windows user DOMAIN\user has been granted group 'ora_dba', you are authorized on the OS-level to log into the database as user SYS.
C:\>sqlplus / as sysdba
SQL>show user
SQL>USER is "SYS"
SQL>shutdown immediate

Add IIS 7 AppPool Identities as SQL Server Logons

I'm running an IIS 7 Website with an AppPool of Integrated Pipeline Mode.
The AppPools does NOT run under NetworkService, etc.. identity (by purpose), but uses its own AppPool Identitiy (IIS AppPool\MyAppPool).
This is a so called service account or virtual account.
(a user account, which is not a full account...)
I'd like to give this service account (IIS AppPool\MyAppPool) permissions to connect to my SQL Server 2008 Express (running in Mixed Auth. Mode).
While SQL Server can add any normal user account, the IIS AppPool\MyAppPool virtual account cannot be added to the valid logons (SQL Server says, that the account cannot be found).
Is there any trick, anything I need to enable to make the virtual accounts work?
(the w3wp.exe process runs under this identity according to taskmgr, but I cannot use the account in NTFS security either...)
Thanks for your help!
The "IIS APPPOOL\AppPoolName" will work, but as mentioned previously, it does not appear to be a valid AD name so when you search for it in the "Select User or Group" dialog box, it won't show up (actually, it will find it, but it will think its an actual system account, and it will try to treat it as such...which won't work, and will give you the error message about it not being found).
How I've gotten it to work is:
In SQL Server Management Studio, look for the Security folder (the security folder at the same level as the Databases, Server Objects, etc. folders...not the security folder within each individual database)
Right click logins and select "New Login"
In the Login name field, type IIS APPPOOL\YourAppPoolName - do not click search
Fill whatever other values you like (i.e., authentication type, default database, etc.)
Click OK
As long as the AppPool name actually exists, the login should now be created.
CREATE LOGIN [IIS APPPOOL\MyAppPool] FROM WINDOWS;
CREATE USER MyAppPoolUser FOR LOGIN [IIS APPPOOL\MyAppPool];
You can solve like this,
Open "Applications Pools",
You should right click that you have choosed application pool. Then choose
"Advanced Settings".
Click three point on the Identity tab then you should choose "LocalSystem" from field of "Built-in-account"
If you do this way, you don't need to create a user in database.
If you're going across machines, you either need to be using NETWORK SERVICE, LOCAL SYSTEM, a domain account, or a SQL 2008 R2 (if you have it) Managed Service Account (which is my preference if you had such an infrastructure). You can not use an account which is not visible to the Active Directory domain.
As a side note processes that uses virtual accounts (NT Service\MyService and IIS AppPool\MyAppPool) are still running under the "NETWORK SERVICE" account as this post suggests http://www.adopenstatic.com/cs/blogs/ken/archive/2008/01/29/15759.aspx. The only difference is that these processes are members of the "NT Service\MyService" or "IIS AppPool\MyAppPool" groups (as these are actually groups and not users). This is also the reason why the processes authenticate at the network as the machine the same way NETWORK SERVICE account does.
The way to secure access is not to depend upon this accounts not having NETWORK SERVICE privileges but to grant more permissions specifically to "NT Service\MyService" or "IIS AppPool\MyAppPool" and to remove permissions for "Users" if necessary.
If anyone has more accurate or contradictional information please post.
Look at: http://www.iis.net/learn/manage/configuring-security/application-pool-identities
USE master
GO
sp_grantlogin 'IIS APPPOOL\<AppPoolName>'
USE <yourdb>
GO
sp_grantdbaccess 'IIS APPPOOL\<AppPoolName>', '<AppPoolName>'
sp_addrolemember 'aspnet_Membership_FullAccess', '<AppPoolName>'
sp_addrolemember 'aspnet_Roles_FullAccess', '<AppPoolName>'
This may be what you are looking for...
http://technet.microsoft.com/en-us/library/cc730708%28WS.10%29.aspx
I would also advise longer term to consider a limited rights domain user, what you are trying works fine in a silo machine scenario but you are going to have to make changes if you move to another machine for the DB server.
I figured it out through trial and error... the real chink in the armor was a little known setting in IIS in the Configuration Editor for the website in
Section: system.webServer/security/authentication/windowsAuthentication
From: ApplicationHost.config <locationpath='ServerName/SiteName' />
called useAppPoolCredentials (which is set to False by default. Set this to True and life becomes great again!!! Hope this saves pain for the next guy....
In my case the problem was that I started to create an MVC Alloy sample project from scratch in using Visual Studio/Episerver extension and it worked fine when executed using local Visual studio iis express.
However by default it points the sql database to LocalDB and when I deployed the site to local IIS it started giving errors some of the initial errors I resolved by:
1.adding the local site url binding to C:/Windows/System32/drivers/etc/hosts
2. Then by editing the application.config found the file location by right clicking on IIS express in botton right corner of the screen when running site using Visual studio and added binding there for local iis url.
3. Finally I was stuck with "unable to access database errors" for which I created a blank new DB in Sql express and changed connection string in web config to point to my new DB and then in package manager console (using Visual Studio) executed Episerver DB commands like -
1. initialize-epidatabase
2. update-epidatabase
3. Convert-EPiDatabaseToUtc
For the ApplicationPoolIdentity, add a login/user in MSSQL as IIS_IUSRS which is corresponding to the default pool.

Resources