IS_OBJECTSIGNED (Transact-SQL)
指示对象由指定证书或非对称密钥签名。
语法
IS_OBJECTSIGNED (
'OBJECT', @object_id, @class, @thumbprint
)
参数
'OBJECT'
安全对象类的类型。@object_id
要测试的对象的 object_id。@object_id 的数据类型为 int。@class
对象的类:“证书”
“非对称密钥”
@class 的数据类型为 sysname。
@thumbprint
对象的 SHA 指纹。@thumbprint 的数据类型为 varbinary(32)。
返回类型
int
注释
IS_OBJECTSIGNED 返回以下值。
返回值 |
说明 |
---|---|
0 |
该对象未签名。 |
1 |
该对象已签名。 |
NULL |
该对象无效。 |
权限
要求对证书或非对称密钥拥有 VIEW DEFINITION 权限。
示例
A. 显示数据库的扩展属性
下面的示例测试 master 数据库中的 spt_fallback_db 表是否由架构签名证书进行签名。
USE master
-- Declare a variable to hold a thumbprint and an object name
DECLARE @thumbprint varbinary(20), @objectname sysname;
-- Populate the thumbprint variable with the thumbprint of
-- the master database schema signing certificate
SELECT @thumbprint = thumbprint
FROM sys.certificates
WHERE name LIKE '%SchemaSigningCertificate%';
-- Populate the object name variable with a table name in master
SELECT @objectname = 'spt_fallback_db';
-- Query to see if the table is signed by the thumbprint
SELECT @objectname AS [object name],
IS_OBJECTSIGNED(
'OBJECT', OBJECT_ID(@objectname), 'certificate', @thumbprint
) AS [Is the object signed?] ;