1

Closed

Members property of SqlAzManApplicationGroup is not functioning

description

Andrea,
My unit tests caught the following bug in "Members" property of SqlAzManApplicationGroup. It's only in version 3.6.0.10. I noticed that you have made some changes to this property but I couldn't figure out why.
Because "this.members" variable is now initialized in the constructor, so the following if statement is always false:
            if (this.members == null && this.GroupType == GroupType.Basic)
            {
                //// MOD: Dictionary creation moved from here fto constructor to handle LDAP Group correctly.
                //// OLD: this.members = new Dictionary<IAzManSid, IAzManApplicationGroupMember>();
                foreach (IAzManApplicationGroupMember m in this.GetApplicationGroupAllMembers())
                {
                    this.members.Add(m.SID, m);
                }
            }
Therefor, "Members" property will always return an empty collection. Even if somehow "this.members" is set to null before coming into the function, an exception will be thrown at this.members.Add.
 
I can't figure out why the change was made, so I can't fix it. Also, I don't know if we had similar changes in other properties.

 
Richard
Closed Feb 2, 2012 at 4:26 AM by tangrl

comments

aferende wrote Jan 31, 2012 at 7:10 AM

tangrl wrote Jan 31, 2012 at 5:00 PM

I don't have ADAM installed so I can't test it. But I guess "members" is assigned a empty dictionary in the constructor just for UI purpose. So the fix should be:

In the constructor:

if(this.groupType != GroupType.Basic)
{
this.members = new Dictionary<IAzManSid, IAzManApplicationGroupMember>();
}

Then restore the "Members" property to the previous version:
    public Dictionary<IAzManSid, IAzManApplicationGroupMember> Members
    {
        get
        {
            if (this.members == null)
            {
                this.members = new Dictionary<IAzManSid, IAzManApplicationGroupMember>();
                foreach (IAzManApplicationGroupMember m in this.GetApplicationGroupAllMembers())
                {
                    this.members.Add(m.SID, m);
                }
            }
            return this.members;
        }
    }
The fix also applies to SqlAzManStoreGroup. Right now if you are using StorageCache and referencing the "Members" properties, you always get a empty dictionary.

Please let me know if my fix looks OK. I'll check in the code ASAP.

Richard

wrote Feb 2, 2012 at 4:26 AM

Resolved with changeset 73900.