hi. is it possible to use a final web content site, using a user with readonly access to DB?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
2/19/2013 4:07:51 AM
Gravatar
Total Posts 192

hi. is it possible to use a final web content site, using a user with readonly access to DB?

Hello.

I want to have web site finalized with content, and then have a sql user with read only access to the db.

I tried, but it fails, because the user needs execute access to stored procudes as well. and hence will have write access too ....

is it by any means possible to access the db with a user with dataread access, and have the site working? (I expect nothing to be written to db)

2/19/2013 10:33:33 AM
Gravatar
Total Posts 18439

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

Only if features that create data are enabled and users have edit permission can data be added to the db. Preventing even Admin users from updating a site is not a goal for the project.

One trick I suppose you could use is to make a copy of the db and use a separate write connection string that points to the copy db so it never writes to the main db. 

2/24/2013 2:52:21 AM
Gravatar
Total Posts 192

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

I tried the trick. but it doesn't work.

I created a fresh site with db1, managed to use it as mainDB, created a normal connection for it, then added another db, db2, as writeConnection.

I tested it with two connection strings.

on application start, it runs the mojoportal-core script correctly on db2.

but it then tries to run 'mp_schemaVersion_SelectOne' on db1, and fails.

any suggestions?

2/24/2013 6:24:07 AM
Gravatar
Total Posts 18439

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

It would only work after both dbs are up to date at the same version after setup has completed on both of them. It would not work during installation or upgrading.

2/24/2013 8:25:35 AM
Gravatar
Total Posts 192

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

I retried with two fresh dbs. it doesn't work. version: 2.3.5.9 MSSQL

sorry. I guess I misunderstood you. you mean the user has full access to both DBs, but writes to a separate db? if you mean this, well this works. I was testing with user having read access to the mainDB.

but I will need to make sure anywhere a write happens, it will use the writeConnectionString.

excuseme for asking thissmiley but have you been carefull with using the writeConnectionString anywhere you needed a write to the db? or there could be some places you missed and used the normal connection for writing to db?

 

2/24/2013 8:55:49 AM
Gravatar
Total Posts 18439

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

I did not say use fresh dbs. I said make a copy of the main db ie backup and restore as a different name. This would be after installation is complete and content has already been finalized not when setting up a new site. The write db must be an exact copy of the populated read db after all content creation has occurred.

I "think" I have been consistent with the write connection string. If you find any places I missed let me know and I will fix them.

Again this is not a goal for the project. If it works for you great.

2/24/2013 10:31:37 AM
Gravatar
Total Posts 192

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

what makes it different?

I created two fresh dbs.

then ran setup for the first db. home came up. again for the second. again home. I though by this point both dbs are Identical and there is no need for backup and restore.

i tried considering the home as the only page and the final content for the test.

then tried changing the application pool user, by a user which had read access to the normal db, and write access to the db with which it connected by writeConnectionString.

it didn't work.

failed on mp_schemaVersion_SelectOne.

Joe, thanks for helping.

2/24/2013 10:40:14 AM
Gravatar
Total Posts 18439

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

2 databases that both run setup are not identical. They have different guids. You don't do what I said and then you complain it doesn't work.

2/24/2013 2:14:11 PM
Gravatar
Total Posts 192

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

Oh my god. sorry for complaining Joe!

I'll try that.

2/24/2013 11:18:56 PM
Gravatar
Total Posts 192

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

I tried that. it doesn't forward me to setup page now, but says mp_sitehosts_selectsiteidbyhost procedure doesn't exist.

I checked the code, the procedure is being called using a readConnectionString, but after searching the net a bit, I came to the conclusion that there is no read-only access to mssql stored procedures. if someone has the permission to execute a stored procedure, he can either write or read. so executing stored procedures needs execute access.

checking all stored procedures for being read_only and then granting execute access to them is also not what I was looking for.

have I done anything wrong?

 

2/25/2013 8:40:15 AM
Gravatar
Total Posts 18439

Re: hi. is it possible to use a final web content site, using a user with readonly access to DB?

I think you do not follow my instructions or you do not know how to make a copy of a database by backup and restore. I just tested it and it works for me. It doesn't matter about exec permissions since the writes happen on the copy it does not update the database in the read connection string and no errors happen for me.

1. Content must be completely created using only MSSQLConnectionString

​2. Make a backup of the database configured in this connection string.

3. Create a new db with a different name, right click it and choose Tasks > Restore > Database

4. Check the radio button "From Device" browse to the backup created in step 2, then check the box once it shows in the list of devices

5. Click Options then check Overwrite Existing DB

6. In the section "Restore the database files as" you must browse and select the files for the db created in step 3

7. After restore is complete set the MSSQLWriteConnectionString to point to the new db

​It works for me. If I edit site content it does not get updated in the read connection string db so no edits appear on the site.

You must sign in to post in the forums. This thread is closed to new posts.