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(); } }
/// <summary>Adds the specified membership user to the collection.</summary> /// <param name="user">A <see cref="T:ClubCloud.Provider.ZimbraMembershipUser" /> object to add to the collection.</param> /// <exception cref="T:System.NotSupportedException">The collection is read-only.</exception> /// <exception cref="T:System.ArgumentNullException">The <see cref="P:ClubCloud.Provider.ZimbraMembershipUser.UserName" /> of the <paramref name="user" /> is null.</exception> /// <exception cref="T:System.ArgumentException">A <see cref="T:ClubCloud.Provider.ZimbraMembershipUser" /> object with the same <see cref="P:ClubCloud.Provider.ZimbraMembershipUser.UserName" /> value as <paramref name="user" /> already exists in the collection.</exception> public void Add(ZimbraMembershipUser user) { if (user == null) { throw new ArgumentNullException("user"); } if (this._ReadOnly) { throw new NotSupportedException(); } int num = this._Values.Add(user); try { this._Indices.Add(user.UserName, num); } catch { this._Values.RemoveAt(num); throw; } }
protected override void FillClaimsForEntity(Uri context, SPClaim entity, SPClaimProviderContext claimProviderContext, List <SPClaim> claims) { //base.FillClaimsForEntity(context, entity, claimProviderContext, claims); string provider = entity.OriginalIssuer.ToLower(); //if (entity.Value.Contains("zimbramembershipprovider") || entity.Value.Contains("zimbraroleprovider")) //if((entity.OriginalIssuer.Contains("ZimbraClaimProvider")) || (entity.Value.Contains("zimbramembershipprovider")) || (entity.Value.Contains("zimbraroleprovider"))) //if (provider.Contains("zimbramembershipprovider") || provider.Contains("zimbraroleprovider") || provider.Contains("zimbraclaimprovider") || provider.Contains("securitytokenservice")) if (provider.Contains("zimbraclaimprovider") || (provider.Contains("securitytokenservice") && entity.Value.Contains("zimbraclaimprovider"))) { //0#.f|zimbramembershipprovider|12073385 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); } } } } } } } } } }
protected override void FillResolve(Uri context, string[] entityTypes, string resolveInput, List <Microsoft.SharePoint.WebControls.PickerEntity> resolved) { if (resolved.Count == 0)// || resolved.Count == 1) { if (resolveInput.Contains("zimbraclaimprovider")) { string identifier = resolveInput.Split('|').Last(); MembershipUser user; if (!string.IsNullOrWhiteSpace(identifier)) { user = Provider.GetUser(identifier, false); } else { user = Provider.GetUser(resolveInput, false); } 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.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; resolved.Add(pe); List <SPClaim> claims = base.GetClaimsForEntity(context, pe.Claim).ToList <SPClaim>(); //FillClaimsForEntity(context, pe.Claim, claims); } } } //MembershipUser user = Provider.GetUser(resolveInput, true); //ZimbraMembershipUser zuser = null; /* * if (user != null && user.GetType() == typeof(ZimbraMembershipUser)) * { * zuser = user as ZimbraMembershipUser; * } */ //if (zuser != null) //{ /* * PickerEntity pe = CreatePickerEntity(); * pe.Claim = new SPClaim(SPClaimTypes.UserLogonName, zuser.uid, "http://www.w3.org/2001/XMLSchema#string", "Forms:ZimbraMembershipProvider"); * //pe.ProviderName = Provider.Name; * //pe.Description = Provider.Description; * pe.DisplayText = zuser.displayName; * pe.EntityType = SPClaimEntityTypes.User; * pe.IsResolved = true; * //pe.EntityGroupName = "Leden"; * pe.EntityData[PeopleEditorEntityDataKeys.DisplayName] = zuser.displayName; * pe.EntityData[PeopleEditorEntityDataKeys.Email] = zuser.Email; * pe.EntityData[PeopleEditorEntityDataKeys.UserId] = zuser.uid; * pe.EntityData[PeopleEditorEntityDataKeys.AccountName] = zuser.uid; * resolved.Add(pe); */ /* * 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; * SPClaim spclaim = CreateClaim(claim.ClaimType, value, claim.ClaimTypeValue); * claims.Add(spclaim); * } * else * { * IList values = (IList)propertyInfo.GetValue(zuser); * if (values != null) * { * foreach (string value in values) * { * SPClaim spclaim = CreateClaim(claim.ClaimType, value, claim.ClaimTypeValue); * claims.Add(spclaim); * } * } * } * } * } */ //} //throw new NotImplementedException(); }
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(); }
/// <summary> /// /// </summary> /// <param name="properties"></param> public override void GroupUserAdded(SPSecurityEventProperties properties) { SPEventReceiverType eventtype = properties.EventType; //if (properties.UserLoginName.Contains("zimbramembershipprovider") || properties.UserLoginName.Contains("zimbraroleprovider")) //{ using (SPSite site = new SPSite(properties.SiteId)) { SPWeb web = site.OpenWeb(properties.WebId); SPList users = web.GetCatalog(SPListTemplateType.UserInformation); if (users != null) { SPListItem luser = users.GetItemById(properties.GroupUserId); string value = luser[ZimbraFieldId.Name] as string; if (!string.IsNullOrWhiteSpace(value)) { try { if (value.Contains("zimbramembershipprovider") || value.Contains("zimbraroleprovider")) { //0#.f|zimbramembershipprovider|12073385 string identifier = value.Split('|').Last(); MembershipUser user; if (!string.IsNullOrWhiteSpace(identifier)) { user = Provider.GetUser(identifier, true); } else { user = Provider.GetUser(value, true); } ZimbraMembershipUser zuser = null; if (user != null && user.GetType() == typeof(ZimbraMembershipUser)) { zuser = user as ZimbraMembershipUser; } if (zuser != null) { luser[ZimbraFieldId.Title] = zuser.displayName; luser[ZimbraFieldId.SipAddress] = zuser.Email; luser.Update(); } } } catch { } } } /* * string identifier = properties.UserLoginName.Split('|').Last(); * MembershipUser user; * if (!string.IsNullOrWhiteSpace(identifier)) * { * user = Provider.GetUser(identifier, true); * } * else * { * user = Provider.GetUser(properties.UserLoginName, true); * } * * ZimbraMembershipUser zuser = null; * if (user != null && user.GetType() == typeof(ZimbraMembershipUser)) * { * zuser = user as ZimbraMembershipUser; * } * * if (zuser != null) * { * * } */ } int id = properties.GroupUserId; string name = properties.GroupUserLoginName; SPUserToken token = properties.OriginatingUserToken; string displayname = properties.UserDisplayName; string loginname = properties.UserLoginName; //base.GroupUserAdded(properties); }