Showing posts with label ids. Show all posts
Showing posts with label ids. Show all posts

Saturday, February 25, 2012

AMO: No mapping between account names and security IDs was done for local users

Hi,

Analysis Services 2005 and SQL Server 2005

Using AMO I'm trying to add a local user to an Analysis Services database Role that I created but I keep getting the error "No mapping between account names and security IDs was done". I can add the user to the Role with no problem using SQL Server Management studio, but if I try to add the user using AMO I get that error.

The local user that I'm trying to add belongs to both the local User and Administrator groups. I've added a logon for this local user to the corresponding SQL Server database that the Analysis Services database datasource points to, but still no luck.

Am I missing something? I've been doing this for the last three months with network users without a problem so this is completely frustrating me. Especially the fact that I can add them using the SQL Server Management Studio GUI.

Here's the basic code that I'm doing. Pretty straightforward.

private bool AddUserToAnalysisServicesRole(Role role)

{

string user = @."pdxvincentm02\testuser";

RoleMember rm = new RoleMember(user);

role.Members.Add(new RoleMember(user)); // e.g. redmond\johndoe

role.Update(); // << KABOOM!!! No mapping between ......

Help. Thanks

I have not had a chance to try this in C# yet, but I did a quick test in powershell using the following pattern and it worked.

role.Members.add("pdxvincentm02\testuser")

role.Update()

It's possible that the role.Members.Add() function has another overload that works a bit differently. But another though also occurred to me. Where is this code being executed from? Is it possibly running under an account that does not have permission to verify the account? (eg. is it running from an ASP.NET app running as local system?)

Thursday, February 9, 2012

Alternative for LEFT() and CHARINDEX() that works with text Data Type

I have a stored procedure that receives a list of ids, to get the emails of each of those ids. The problem that I'm having is that I'm using a char data type that is max length is 8000, but the contact lists are getting bigger and soon they might reach the variable max length. The contact list that I receive will look something like this "1234,67523,67875,789687,", I'm using "," as a separator. Right now what I do is this

@.array_value=LEFT(@.ContactList, @.separator_position- 1)

The LEFT function doesn't work with data types text and ntext. But I'm in need of a string data type with a max length bigger than 8000. So I will apreciate if anyone knows of another function that does the same or similar and works with text data type, or any other ideas will be welcome.

Thanks,

Erick

what database & version are you using?

|||

SQL Server 2005

|||

Use varchar(max) instead of varchar(8000) then.

|||

Can you change the datatype? Try using varchar(MAX) or nvarchar(MAX). MSDN says built-in string functions have been built to work with the new large object types (MAX).

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

|||

I just changed, I didn't know that worked. I just read thats new in sql 2005, that didn't work on 2000.

Thanks

|||

That worked but, Can I give max value to varchar in asp.net vb?

|||

http://msdn2.microsoft.com/en-us/library/a1904w6t(VS.80).aspx

|||

It looks like you just set the type to the normal DBType, i.e. use varchar for varchar(MAX), then set the length to -1 (this tells the parameter to use whatever length the data is, rather than specifying how much of the data to use).