[Resolved] Problem with EnumObjectPermissions for the login account

Dec 19, 2011 at 4:30 PM
Edited Dec 19, 2011 at 4:31 PM

Hi all,

I think I have a problem with EnumObjectPermissions  which should "enumerates a list of object permissions for the login account", but I have no answer.

Here is my test script :

 

$server = New-Object 'Microsoft.sqlserver.management.smo.server' "XXXXXX\yyy"

$login=$server.logins| ?{ @('SBI_test_login') -contains $_.name}

$login.EnumObjectPermissions()

I know I have permissions as the sys.server_permissions table contains the following records :

GRANT  ALTER ANY CREDENTIAL  SBI_test_login

GRANT  CONNECT SQL SBI_test_login

GRANT  CREATE ANY DATABASE SBI_test_login

 

Do you have any idea?

 

 


Coordinator
Dec 20, 2011 at 1:38 AM

You're right that doesn't work and there doesn't appear to be a method on the login class to see server permissions assigned to a login, however there is a method on the server class you can use:

$server.EnumServerPermissions("SBI_test_login") will return the permissions also server.EnumServerPermissions will return all server permissions for all logins.

Dec 20, 2011 at 2:45 PM

thanks.