private void AddNonADEntry(MapiAclTableAdapter mapiAclTableAdapter, ref ExternalUserCollection externalUsers, string memberName, long memberId, byte[] memberEntryId, MemberRights rights) { ExternalUser externalUser = mapiAclTableAdapter.TryGetExternalUser(memberEntryId, ref externalUsers); if (externalUser != null) { PermissionSecurityPrincipal securityPrincipal = new PermissionSecurityPrincipal(externalUser); Permission permission = this.permissionSet.CreatePermission(securityPrincipal, rights, memberId); this.AddPermissionEntry(securityPrincipal, permission); return; } ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "PermissionTable::PermissionTable. Member has invalid entry id, member name = {0}.", memberName); this.AddUnknownEntry(memberName, memberId, memberEntryId, rights); }
private MapiAclTableRestriction.ExternalUserPermission TryGetExternalUserPermission(AclTableEntry aclTableEntry, MapiAclTableAdapter mapiAclTableAdapter, ref ExternalUserCollection externalUsers) { Util.ThrowOnNullArgument(aclTableEntry, "aclTableEntry"); Util.ThrowOnNullArgument(mapiAclTableAdapter, "mapiAclTableAdapter"); MailboxSession mailboxSession = this.session as MailboxSession; if (mailboxSession == null) { return(null); } byte[] memberEntryId = aclTableEntry.MemberEntryId; MemberRights memberRights = aclTableEntry.MemberRights; long memberId = aclTableEntry.MemberId; if (memberEntryId == null || memberEntryId.Length == 0) { if (memberId <= 0L) { return(null); } ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal, long>((long)this.GetHashCode(), "{0}: Getting memberEntryId from current ACL table for MemberId {1}.", mailboxSession.MailboxOwner, memberId); AclTableEntry byMemberId = mapiAclTableAdapter.GetByMemberId(memberId); if (byMemberId == null || byMemberId.MemberEntryId == null) { ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal, long>((long)this.GetHashCode(), "{0}: Not found memberEntryId from current ACL table for MemberId {1}. Skipped.", mailboxSession.MailboxOwner, memberId); return(null); } memberEntryId = byMemberId.MemberEntryId; } if (mapiAclTableAdapter.TryGetParticipantEntryId(memberEntryId) != null) { ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: MemberEntryId indicates internal user. Skipped.", mailboxSession.MailboxOwner); return(null); } ExternalUser externalUser = mapiAclTableAdapter.TryGetExternalUser(memberEntryId, ref externalUsers); if (externalUser == null) { ExTraceGlobals.StorageTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: MemberEntryId is not external user. Skipped.", mailboxSession.MailboxOwner); return(null); } return(new MapiAclTableRestriction.ExternalUserPermission(externalUser, memberRights)); }