Integrating external membership

Untra stores all members in Umbraco membership and cache them in a simple memory cache of the Uintra app. To use a external membership provider( f.e. ActiveDirectory, Custom CRM, External Db) there are two possible ways to go explained below:

First scenario:


1. Replace Umbraco membership with another membership

This scenario is the easiest and probably most suitable:

a. First override "IntranetUserServiceBase.cs":

  1. protected virtual T GetFromSql(Guid id)
  2.         {
  3.                 var member = _memberService.GetByKey(id);
  4.                 return member != null ? Map(member) : default(T);
  5.         }
  6.         protected virtual IEnumerable<T> GetAllFromSql()
  7.         {
  8.                 var members = _memberService.GetAllMembers().Select(Map).ToList();
  9.                 return members;
  10.         }

b. Continue by replaceing "_memberService" with your custom service which gets members from external storage

c. Create your own Map method using your custom member mode


Second scenario:


2. Get members from external storage and put them in Umbraco membership. 
In this scenario you need to write you own service which gets all members from your external storage and use Save(IntranetUserDTO user) from IntranetUserServiceBase.cs

a. But first you need to override it:

  1. public virtual void Save(IntranetUserDTO user)
  2.         {
  3.                 var member = _memberService.GetByKey(user.Id);
  4.                 member.SetValue(ProfileConstants.FirstName, user.FirstName);
  5.                 member.SetValue(ProfileConstants.LastName, user.LastName);
  6.                 if (user.NewMedia.HasValue)
  7.                         {
  8.                                 member.SetValue(ProfileConstants.Photo, user.NewMedia.Value);
  9.                         }
  10.                 if (user.DeleteMedia)
  11.                         {
  12.                                 member.SetValue(ProfileConstants.Photo, null);
  13.                         }
  14.                 _memberService.Save(member, raiseEvents: false);
  15.                 UpdateUserCache(user.Id);
  16.         }

b. Then create a new member in Umbraco membership:  

        var member = _memberService.CreateMember()

c. Get them and extend with your custom prop:

  1. var member = _memberService.GetByKey(user.Id);
  2.         member.SetValue(ProfileConstants.FirstName, user.FirstName);
  3.         member.SetValue(ProfileConstants.LastName, user.LastName);
  4.         member.SetValue("your custom ", value );

d. Then put the member Id in the cache "UpdateUserCache(user.Id);"
e. Also you need provide mapping between you external member model to 

 You also able to extend 
IntranetUserDTO with your custom properties by creating derived model from IntranetUserDTO

Didn't find what you were looking for?

Our site is a work in progress and feedback is very much appreciated. If you could not find information regarding your problem please contact or go to our github and create an issue if the problem relates to a bug or otherwise unintended technical functionality.