0

COM インターフェイスである Authorization manager (AzMan) API を呼び出す WCF サービスがあります。次のコードを使用して、特定のユーザー アカウントのロールのリストを取得します。

public string[] GetRoleNamesForUser(string appName, SecurityIdentifier userSID)
{
    m_azManStore.UpdateCache(null);
    IAzApplication app = GetApplication(appName);
    List<string> userRoles = new List<string>();
    if (userSID != null)
    {
        IAzClientContext context = app.InitializeClientContextFromStringSid(userSID.ToString(), 1, null);
        object[] roles = (object[])context.GetRoles("");
        foreach (string uRole in roles)
        {
            userRoles.Add(uRole);
        }
        Marshal.FinalReleaseComObject(context);
    }
    return userRoles.ToArray();
}

ほとんどの場合、このコードは問題なく動作します。ただし、負荷テスト中 (常に同じ userSID を使用)、このコードはロールのリストに対して空の配列を返すことがあります。AzMan には負荷が高いという問題がありますか、それとも AzMan COM オブジェクトなどに関して私が正しく行っていないことがありますか?

4

1 に答える 1

1

When using the AzMan COM object you must use Marshal.FinalReleaseCOMObject(object) to release resources. A memory leak is possible if this is not done. I had to wrap the AzMan store in a disposable class so that each call would open AzMan, use it then close it. The result is a slower, but more stable, application.

Take a look at this SO question for more details

于 2011-01-24T23:15:52.320 に答える