Showing posts with label roles. Show all posts
Showing posts with label roles. Show all posts

Wednesday, March 7, 2012

An attempt to attach an auto-named database for file

I build a WebApp which i use the default DataBase that come with the App_Data folder.

I have Users and roles into that folder with all my tables regarding my new App.

Why i cant make it work under IIS on my webserver ? When i open it with Visual Studio everything works but outside of it nothing.

An attempt to attach an auto-named database for file c:\inetpub\wwwroot\Survey\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf;

I look arround and cant find a thing on how to fix my issue. I try deleting the Folder under my User Account for SQL Express and nothing happend.

Make sure your IIS account (ASPNET or NETWORK SERVICE) has read&write permission on the folder where the database file locates.|||Yes i did that ! even uers have modify to it. under that folder !|||

Im still looking for help arround here !

anybody fix the issue?

|||

It is not working because IIS is not the place to store database files, you store those in the data subfolder of Microsoft SQL Server in programs. You can modify the code in the thread below for your use. You may need to start with the trail version of SQL Server and later buy the developer edition it is under $40 on the web. Hope this helps.

http://forums.asp.net/thread/977493.aspx

Friday, February 24, 2012

AMO Security Scripting Problem

Hi!

I have a little program that creates roles for a catalog and cubes. The roles is created fine and all the read permissions on the different cubes as well. Also adding different users to the roles is no problem.

Then when i look in BIDS( open analysis services database) everything looks exactly as it should. However, the different roles does not work for the users that are added through the script. But, if i manually add a user to one of the created roles, it works for that user. Anybody who knows what is going on?

The roles both have users and user groups in them.

You say "However, the different roles does not work for the users that are added through the script."

What script you are talking about? How do you generate the script? What doesnt work exactly?

Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.

|||If you 'script' a role, the script just contains the names of the role members, NOT the permissions. Those permissions are stored in the cubes and dimensions themselves. So be carefull by changing permissions with scripts. It was not clear from your description if you just wanted o add users, or you created new roles as well. In the latter case, this can be an explanation, in the former case, you must have bumped onto another problem as well.|||

Hi!

This is basically what i do.

Role role = _oDb.Roles.Add(_sRoleID);

role.Members.Add(new RoleMember("domain\user");

role.Update();

Cube cube = _oDb.Cubes.FindByName(sCube);

if (cube != null)
{
CubePermission cubeperm = cube.CubePermissions.Add(_sRoleID);
cubeperm.Read = ReadAccess.Allowed;
cubeperm.ReadSourceData = ReadSourceDataAccess.Allowed;
cubeperm.Update();
}


So it′s not any advanced type of security, just read or not read a cube. If i then look at this role, by opening it with BIDS(opening the cube online, not a project), it looks fine. All the users are there and the read permissions and so on. But the users can′t access the cubes. If i then delete a user from a created role, and then add it again by hand, they can access the cube. So the role works, but it is like it does not like the programmatically added user names, even though they are exactly the same as when i add it by hand. And i don′t think it is all that different from this bol entry

http://msdn2.microsoft.com/en-us/library/ms345081.aspx

However, i just saw something in that entry that i missed. And it was the DatabasePermission which i don′t do anything with. It might be that, i will check. But that has Role as input so the deleting and adding a user by hand on a role should not affect that or BIDS does that under the covers or something?

|||

Full of shame and have a appointment whith the eye doctor.

It was the databasepermission that was missing. Thanks!

AMO Role drop trouble

I've some trouble trying to drop roles with AMO and the following code:


Role oCurrentRole = oOLAPDB.Roles.GetByName(<role name>);
oCurrentRole.Drop(DropOptions.AlterOrDeleteDependents);

Most of the time it's OK but I've sometimes this error

Exception non gre : System.InvalidOperationException: Impossible de supprimer l'objet ? Role ?my role , il doit faire partie d'un objet Server connect.
à Microsoft.AnalysisServices.MajorObject.DropPrivate(DropOptions options, XmlaWarningCollection warnings, ImpactDetailCollection impactResult, Boolean analyzeImpactOnly)
à Microsoft.AnalysisServices.MajorObject.Drop(DropOptions options)

(in english: Unhandled exception : System.InvalidOperationException: Unable to drop ? Role object ?my role , it must be part of a connected Server object)

I'm the only one connected to this server and I'm sure this role isn't used.

One thing to mention: It seems I've this error only with roles with members which are no more existing in the domain (they were when the role was created but get deleted later).

Any idea ? How could I drop these roles with AMO ?

David,

I created an account on my local system, JunkUser, and then created a role in Adventure Works DW called JunkRole. JunkUser is the lone member of this role. I then dropped the JunkUser account from my system.

In SSIS, I created a package with a single Script task. I added the AMO reference and an Imports statement to simplify my code. In Sub Main, I added this code:

Code Snippet

Dim MyServer As New Server

MyServer.Connect(".")

Dim MyDatabase As Database = MyServer.Databases.GetByName("Adventure Works DW")

Dim MyRole As Role = MyDatabase.Roles.GetByName("JunkRole")

MyRole.Drop(DropOptions.AlterOrDeleteDependents)

MyServer.Disconnect()

I executed the SSIS package. It completed successsfully and I verified the JunkRole had been dropped.

I am running on SP2.

Not sure what might else may be causing the problem you are seeing.

B.

|||My bad Sad

You're right Bryan, it doens't matter if the user has been deleted or not

In fact, I had a nice
oServer.Disconnect();
just before my code... And of course, oServer is my OLAP Server object... Now that I'm thinking about it, the error message was quite explicit ("...connected Server") Sad