• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            牽著老婆滿街逛

            嚴以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            Getting the Logon SID in C++

            A logon security identifier (SID) identifies the logon session associated with an access token. A typical use of a logon SID is in an ACE that allows access for the duration of a client's logon session. For example, a Windows service can use the LogonUser function to start a new logon session. The LogonUser function returns an access token from which the service can extract the logon SID. The service can then use the SID in an ACE that allows the client's logon session to access the interactive window station and desktop.

            The following example gets the logon SID from an access token. It uses the GetTokenInformation function to fill a TOKEN_GROUPS buffer with an array of the group SIDs from an access token. This array includes the logon SID, which is identified by the SE_GROUP_LOGON_ID attribute. The example function allocates a buffer for the logon SID; it is the caller's responsibility to free the buffer.

            BOOL?GetLogonSID?(HANDLE?hToken,?PSID? * ppsid)?
            {
            ???BOOL?bSuccess?
            = ?FALSE;
            ???DWORD?dwIndex;
            ???DWORD?dwLength?
            = ? 0 ;
            ???PTOKEN_GROUPS?ptg?
            = ?NULL;

            // ?Verify?the?parameter?passed?in?is?not?NULL.
            ???? if ?(NULL? == ?ppsid)
            ????????
            goto ?Cleanup;

            // ?Get?required?buffer?size?and?allocate?the?TOKEN_GROUPS?buffer.

            ???
            if ?( ! GetTokenInformation(
            ?????????hToken,?????????
            // ?handle?to?the?access?token
            ?????????TokenGroups,???? // ?get?information?about?the?token's?groups?
            ?????????(LPVOID)?ptg,??? // ?pointer?to?TOKEN_GROUPS?buffer
            ????????? 0 ,?????????????? // ?size?of?buffer
            ????????? & dwLength??????? // ?receives?required?buffer?size
            ??????))?
            ???
            {
            ??????
            if ?(GetLastError()? != ?ERROR_INSUFFICIENT_BUFFER)?
            ?????????
            goto ?Cleanup;

            ??????ptg?
            = ?(PTOKEN_GROUPS)HeapAlloc(GetProcessHeap(),
            ?????????HEAP_ZERO_MEMORY,?dwLength);

            ??????
            if ?(ptg? == ?NULL)
            ?????????
            goto ?Cleanup;
            ???}


            // ?Get?the?token?group?information?from?the?access?token.

            ???
            if ?( ! GetTokenInformation(
            ?????????hToken,?????????
            // ?handle?to?the?access?token
            ?????????TokenGroups,???? // ?get?information?about?the?token's?groups?
            ?????????(LPVOID)?ptg,??? // ?pointer?to?TOKEN_GROUPS?buffer
            ?????????dwLength,??????? // ?size?of?buffer
            ????????? & dwLength??????? // ?receives?required?buffer?size
            ?????????))?
            ???
            {
            ??????
            goto ?Cleanup;
            ???}


            // ?Loop?through?the?groups?to?find?the?logon?SID.

            ???
            for ?(dwIndex? = ? 0 ;?dwIndex? < ?ptg -> GroupCount;?dwIndex ++ )?
            ??????
            if ?((ptg -> Groups[dwIndex].Attributes? & ?SE_GROUP_LOGON_ID)
            ?????????????
            == ??SE_GROUP_LOGON_ID)?
            ??????
            {
            ??????
            // ?Found?the?logon?SID;?make?a?copy?of?it.

            ?????????dwLength?
            = ?GetLengthSid(ptg -> Groups[dwIndex].Sid);
            ?????????
            * ppsid? = ?(PSID)?HeapAlloc(GetProcessHeap(),
            ?????????????????????HEAP_ZERO_MEMORY,?dwLength);
            ?????????
            if ?( * ppsid? == ?NULL)
            ?????????????
            goto ?Cleanup;
            ?????????
            if ?( ! CopySid(dwLength,? * ppsid,?ptg -> Groups[dwIndex].Sid))?
            ?????????
            {
            ?????????????HeapFree(GetProcessHeap(),?
            0 ,?(LPVOID) * ppsid);
            ?????????????
            goto ?Cleanup;
            ?????????}

            ?????????
            break ;
            ??????}


            ???bSuccess?
            = ?TRUE;

            Cleanup:?

            // ?Free?the?buffer?for?the?token?groups.

            ???
            if ?(ptg? != ?NULL)
            ??????HeapFree(GetProcessHeap(),?
            0 ,?(LPVOID)ptg);

            ???
            return ?bSuccess;
            }


            The following function frees the buffer allocated by the GetLogonSID example function.
            VOID?FreeLogonSID?(PSID?*ppsid)?
            {
            ????HeapFree(GetProcessHeap(),?
            0,?(LPVOID)*ppsid);
            }

            posted on 2006-04-14 21:31 楊粼波 閱讀(333) 評論(0)  編輯 收藏 引用 所屬分類: 文章收藏

            久久人人爽人人爽人人片AV不| 亚洲狠狠综合久久| 久久久久青草线蕉综合超碰| 精品无码久久久久国产动漫3d| 久久亚洲精品成人av无码网站| 91久久香蕉国产熟女线看| 久久久噜噜噜久久中文字幕色伊伊| 色综合久久久久无码专区 | 97久久超碰国产精品2021| 国产精品免费看久久久香蕉| 亚洲va久久久噜噜噜久久| 精品精品国产自在久久高清 | 国产精品嫩草影院久久| 国产成人综合久久精品红| 中文字幕亚洲综合久久2| 亚洲精品美女久久久久99| 久久久久亚洲AV成人网人人网站| 久久亚洲国产成人精品性色 | 久久久一本精品99久久精品88| 久久成人精品| 久久精品中文字幕久久| 久久国产色AV免费观看| 中文字幕乱码人妻无码久久| 欧美精品丝袜久久久中文字幕| 久久精品中文字幕久久| 99久久免费国产精品热| 久久久久女人精品毛片| 国产A三级久久精品| 一本一本久久aa综合精品| 久久频这里精品99香蕉久| 蜜臀久久99精品久久久久久| 久久精品成人免费观看97| 国内精品久久久久久久coent| 色综合久久久久网| 99久久婷婷国产一区二区| 99久久国产免费福利| 国产精品免费久久久久久久久| 国产精品日韩深夜福利久久| 久久久久久久久久免免费精品 | 国产三级久久久精品麻豆三级| 蜜臀av性久久久久蜜臀aⅴ|