共用方式為


查詢用戶端內容

應用程式可以呼叫 AuthzGetInformationFromCoNtext 函式來查詢現有用戶端內容的相關資訊。

AuthzGetInformationFromCoNtext函式的InfoClass參數會從AUTHZ_CONTEXT_INFORMATION_CLASS列舉取得值,指定函式查詢的資訊類型。

如果在條件運算式中參考,安全性屬性變數必須存在於用戶端內容中;否則,參考條件運算式的詞彙將會評估為未知。 如需條件運算式的詳細資訊,請參閱 條件式 ACE 的安全性描述元定義語言 主題。

範例

下列範例會從 初始化用戶端內容 查詢範例中建立的用戶端內容,以擷取與該用戶端內容相關聯之群組的 SID 清單。

BOOL GetGroupsFromContext(AUTHZ_CLIENT_CONTEXT_HANDLE hClientContext)
{

    DWORD                cbSize = 0;
    PTOKEN_GROUPS        pTokenGroups=NULL;
    LPTSTR                StringSid = NULL;
    BOOL                bResult = FALSE;
    int i = 0;

    //Call the AuthzGetInformationFromContext function with a NULL output buffer to get the required buffer size.
    AuthzGetInformationFromContext(hClientContext, AuthzContextInfoGroupsSids, 0, &cbSize, NULL);
    
        
    

    //Allocate the buffer for the TOKEN_GROUPS structure.
    pTokenGroups = (PTOKEN_GROUPS)malloc(cbSize);
    if (!pTokenGroups)
        return FALSE;

    //Get the SIDs of groups associated with the client context. 
    if(!AuthzGetInformationFromContext(hClientContext, AuthzContextInfoGroupsSids, cbSize, &cbSize, pTokenGroups))
    {    
        printf_s("AuthzGetInformationFromContext failed with %d\n", GetLastError);
        free(pTokenGroups);
        return FALSE;
    }

    //Enumerate and display the group SIDs.
    for (i=pTokenGroups->GroupCount-1; i >= 0; --i)
    {
        //Convert a SID to a string.
        if(!ConvertSidToStringSid(
            pTokenGroups->Groups[i].Sid,
            &StringSid
            ))
        {
            LocalFree(StringSid);
            return FALSE;
        }


        wprintf_s(L"%s \n", StringSid);
        
    }

    free(pTokenGroups);

    return TRUE;
}

將 SID 新增至用戶端內容

快取存取檢查

使用 Authz API 檢查存取

AccessCheck 的運作方式

初始化用戶端內容

條件式 ACE 的安全性描述元定義語言