Beispiel #1
0
        protected override void FillResolve(Uri context, string[] entityTypes, Microsoft.SharePoint.Administration.Claims.SPClaim resolveInput, List <Microsoft.SharePoint.WebControls.PickerEntity> resolved)
        {
            //PickerEntity[] baseResolved = base.Resolve(context, entityTypes, resolveInput);
            //List<SPClaim> claims = base.GetClaimsForEntity(context,resolveInput).ToList<SPClaim>();
            //FillClaimsForEntity(context, resolveInput, claims);
            string provider = resolveInput.OriginalIssuer.ToLower();

            //if (resolveInput.OriginalIssuer.Contains("zimbramembershipprovider") || resolveInput.OriginalIssuer.Contains("zimbraroleprovider") || resolveInput.OriginalIssuer.Contains("zimbraclaimprovider"))
            //if (provider.Contains("zimbramembershipprovider") || provider.Contains("zimbraroleprovider") || provider.Contains("zimbraclaimprovider"))
            if (provider.Contains("zimbraclaimprovider"))
            {
                if (resolved.Count == 0)// || resolved.Count == 1)
                {
                    string         identifier = resolveInput.Value.Split('|').Last();
                    MembershipUser user;
                    if (!string.IsNullOrWhiteSpace(identifier))
                    {
                        user = Provider.GetUser(identifier, true);
                    }
                    else
                    {
                        user = Provider.GetUser(resolveInput.Value, true);
                    }

                    //MembershipUser user = Provider.GetUser(resolveInput.Value, true);
                    ZimbraMembershipUser zuser = null;
                    if (user != null && user.GetType() == typeof(ZimbraMembershipUser))
                    {
                        zuser = user as ZimbraMembershipUser;
                    }

                    if (zuser != null)
                    {
                        PickerEntity pe = CreatePickerEntity();
                        //pe.Claim = base.CreateClaim(SPClaimTypes.UserLogonName, zuser.uid, "http://www.w3.org/2001/XMLSchema#string");
                        pe.Claim       = resolveInput;
                        pe.DisplayText = zuser.displayName;
                        pe.EntityType  = SPClaimEntityTypes.User;
                        pe.IsResolved  = true;
                        pe.EntityData[PeopleEditorEntityDataKeys.DisplayName] = zuser.displayName;
                        pe.EntityData[PeopleEditorEntityDataKeys.Email]       = zuser.Email;
                        pe.EntityData[PeopleEditorEntityDataKeys.SIPAddress]  = zuser.Email;
                        pe.EntityData[PeopleEditorEntityDataKeys.UserId]      = zuser.uid;
                        pe.EntityData[PeopleEditorEntityDataKeys.AccountName] = zuser.uid;
                        //pe.ProviderName = resolveInput.OriginalIssuer;
                        //pe.Description = resolveInput.OriginalIssuer + ":" + zuser.displayName;
                        List <SPClaim> claims = base.GetClaimsForEntity(context, pe.Claim).ToList <SPClaim>();
                        resolved.Add(pe);
                    }
                }
                //FillResolve(context, entityTypes, resolveInput.Value, resolved);
                //throw new NotImplementedException();
            }
        }
Beispiel #2
0
        protected override void FillClaimsForEntity(Uri context, Microsoft.SharePoint.Administration.Claims.SPClaim entity, List <Microsoft.SharePoint.Administration.Claims.SPClaim> claims)
        {
            string provider = entity.OriginalIssuer.ToLower();

            //if ((entity.OriginalIssuer.Contains("ZimbraClaimProvider")) || (entity.OriginalIssuer.Contains("ZimbraMembershipProvider")) || (entity.OriginalIssuer.Contains("ZimbraRoleProvider")))
            //if (provider.Contains("zimbramembershipprovider") || provider.Contains("zimbraroleprovider") || provider.Contains("zimbraclaimprovider"))
            if (provider.Contains("zimbraclaimprovider"))
            {
                string         identifier = entity.Value.Split('|').Last();
                MembershipUser user;
                if (!string.IsNullOrWhiteSpace(identifier))
                {
                    user = Provider.GetUser(identifier, true);
                }
                else
                {
                    user = Provider.GetUser(entity.Value, true);
                }

                ZimbraMembershipUser zuser = null;
                if (user != null && user.GetType() == typeof(ZimbraMembershipUser))
                {
                    zuser = user as ZimbraMembershipUser;
                }

                if (zuser != null)
                {
                    Type                      tuser        = zuser.GetType();
                    PropertyInfo[]            properties   = tuser.GetProperties();
                    IEnumerable <ZimbraClaim> zimbraClaims = ZimbraClaimsMapped.Claims.Where(x => x.ClaimTypeValue != null);

                    foreach (ZimbraClaim claim in zimbraClaims)
                    {
                        PropertyInfo propertyInfo = properties.SingleOrDefault(p => p.Name == claim.Name);
                        if (propertyInfo != null && propertyInfo.Name == claim.Name)
                        {
                            if (propertyInfo.PropertyType == typeof(string))
                            {
                                string value = propertyInfo.GetValue(zuser) as string;
                                if (!string.IsNullOrWhiteSpace(value))
                                {
                                    SPClaim spclaim = CreateClaim(claim.ClaimType, value, claim.ClaimTypeValue);
                                    if (!claims.Contains(spclaim))
                                    {
                                        claims.Add(spclaim);
                                    }
                                }
                            }
                            else
                            {
                                IList values = (IList)propertyInfo.GetValue(zuser);
                                if (values != null)
                                {
                                    foreach (string value in values)
                                    {
                                        if (!string.IsNullOrWhiteSpace(value))
                                        {
                                            SPClaim spclaim = CreateClaim(claim.ClaimType, value, claim.ClaimTypeValue);
                                            if (!claims.Contains(spclaim))
                                            {
                                                claims.Add(spclaim);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //throw new NotImplementedException();
        }