Showing posts with label call. Show all posts
Showing posts with label call. Show all posts

Thursday, March 29, 2012

EnumObjectPermissions on a ApplicationRole and DatabaseRole objects returns o entries

HI,

Call to EnumObjectPermissions method on a SMO ApplicationRole or DatabseRole object returns an empty collection, however, a call to EnumDatabaseRoleMember on a DatabaseRole object using DMO returns the correct list of membership. Please clarify.

Regards,

Joginder

Hmm I had the same problem with SMO, but I did not try DMO.

I found a workaround. Use the similar method at the Database level, and supply the role name as a string.

using Microsoft.SqlServer.Management.Smo;

using Microsoft.SqlServer.Management.Common;

Database dbHold = smoServer.Databases["YourDB"];

String holdString;

foreach( DatabaseRole dr in dbHold.Roles)

{

ObjectPermissionInfo[] ra = dr.EnumObjectPermissions(); // mysteriously returns null!!

foreach (ObjectPermissionInfo opi in dbHold.EnumObjectPermissions(dr.Name))

{

holdString = String.Format("-OPIRole:{0} has {1}{2}{3}", dr.Name, opi.Grantor, opi.Grantee, opi.ObjectName);

}

}

}

Regards,

Chip

EnumObjectPermissions on a ApplicationRole and DatabaseRole objects returns o entries

HI,

Call to EnumObjectPermissions method on a SMO ApplicationRole or DatabseRole object returns an empty collection, however, a call to EnumDatabaseRoleMember on a DatabaseRole object using DMO returns the correct list of membership. Please clarify.

Regards,

Joginder

Hmm I had the same problem with SMO, but I did not try DMO.

I found a workaround. Use the similar method at the Database level, and supply the role name as a string.

using Microsoft.SqlServer.Management.Smo;

using Microsoft.SqlServer.Management.Common;

Database dbHold = smoServer.Databases["YourDB"];

String holdString;

foreach( DatabaseRole dr in dbHold.Roles)

{

ObjectPermissionInfo[] ra = dr.EnumObjectPermissions(); // mysteriously returns null!!

foreach (ObjectPermissionInfo opi in dbHold.EnumObjectPermissions(dr.Name))

{

holdString = String.Format("-OPIRole:{0} has {1}{2}{3}", dr.Name, opi.Grantor, opi.Grantee, opi.ObjectName);

}

}

}

Regards,

Chip

Enumerating jobs on a SQL server using SMO - in C#

Hi all, I'm trying to connect to SQL and enumerate all Agent jobs to find a
particular and call job.envoke on it.
Looked every where but can't find a code snippet on it or a sample.
Anyone can assist? CheersYou can use this to list all the jobs.
USE msdb
EXEC sp_help_job
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/|||Oops... Just read the subject line about SMO.. My fault..
You can try this link..
http://msdn2.microsoft.com/en-us/li...nt.
aspx
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/|||Thanks omnibuzz, I've tried that uri but since I'm new to SQL prog I haven't
figured out how to use for instance jobbasecollection classes to find out if
the job I'm interested in exist on the server.
Any help there with the code\implementation? Thanks.
"Omnibuzz" wrote:

> Oops... Just read the subject line about SMO.. My fault..
> You can try this link..
> http://msdn2.microsoft.com/en-us/li...n
t.aspx
> --
> -Omnibuzz (The SQL GC)
> http://omnibuzz-sql.blogspot.com/
>
>