diff --git a/roles/karaage3.1.17/templates/karaage3-wsgi.conf.j2 b/roles/karaage3.1.17/templates/karaage3-wsgi.conf.j2
index 360abc8bfdf37d9bdd0bb1a04a62a14618d196a2..ac304e225223f4eb32200b590b211d28da734ef2 100644
--- a/roles/karaage3.1.17/templates/karaage3-wsgi.conf.j2
+++ b/roles/karaage3.1.17/templates/karaage3-wsgi.conf.j2
@@ -38,6 +38,13 @@ ShibUseHeaders On
 require valid-user
 </Location>
 
+<Location /karaage/projects/joinprojects/>
+AuthType Shibboleth
+ShibRequireSession On
+ShibUseHeaders On
+require valid-user
+</Location>
+
 <Location /karaage/profile/slogin>
 AuthType Shibboleth
 ShibRequireSession On
diff --git a/roles/karaage3.1.17/templates/kg-idps.j2 b/roles/karaage3.1.17/templates/kg-idps.j2
index 59400470a8bf83c5754fe483a841ccd14d5b739e..c4e4c5b355ccfb505cba79ea66b4660a819c7350 100755
--- a/roles/karaage3.1.17/templates/kg-idps.j2
+++ b/roles/karaage3.1.17/templates/kg-idps.j2
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import os, sys
+import os, sys, traceback
 import django
 os.environ['DJANGO_SETTINGS_MODULE'] = "karaage.conf.settings"
 
@@ -23,50 +23,33 @@ def get_idps_from_metadata(cache_path):
         
     return idps
 
-def get_next_idp_group():
-    from karaage.people.models import Group
-    i=-1
-    available=False
-    nextgroup=None
-    groupname='idpgroup{idx}'
-    while not available:
-        i=i+1
-        try:
-            group =Group.objects.get(name=groupname.format(idx=i))
-        except Group.DoesNotExist:
-            available=True
-            nextgroup=groupname.format(idx=i)
-    return nextgroup
-
-
 def get_or_create_idp(entityID,name):
-    print "get_or_create %s"%name
     from karaage.institutes.forms import InstituteForm
     from karaage.institutes.models import Institute
     from karaage.people.models import Group
     try:
-        Institute.objects.get(saml_entityid=entityID)
+        print "Check institute name = '%s', entityID = '%s'" %(name, entityID)
+        institute = Institute.objects.get(saml_entityid=entityID)
+        if institute:
+            print "Find institute name = '%s', saml_entityid = '%s', group name = '%s'" %(institute.name, institute.saml_entityid, institute.group.name)
+        else: 
+            print "Institute name = '%s', entityID = '%s' not found" %(name, entityID)
         return
     except Institute.DoesNotExist:
-        print "does not exists, creating"
-        groupname=get_next_idp_group()
-        group, _ =Group.objects.get_or_create(name=groupname)
-        institute=Institute(name=name,group=group,saml_entityid=entityID,is_active=True)
-        institute.save()
-#
-#        d={}
-#        d['name']=name
-#        d['group_id']=group
-#        d['saml_entityid']=entityID
-#        d['is_active']=True
-#        form=InstituteForm(d)
-#        if form.is_valid():
-#            print "tying to save"
-#            form.save()
-#        else:
-#            print "form not valid"
-#            print dir(form)
-#            #print "not actually saving my form"
+        try:
+            group, _ =Group.objects.get_or_create(name = name)
+            if group:
+                print "Get group name = '%s'" %(group.name)
+                institute = Institute(name = name, group = group, saml_entityid = entityID, is_active = True)
+                if institute:
+                    print "Create institute OK: name = '%s', saml_entityid = '%s', group nane = '%s'" %(institute.name, institute.saml_entityid, institute.group.name)
+                    institute.save()
+                else:
+                    print "Create institute name = '%s', entityID = '%s' failed" %(name, entityID)
+            else:
+                print "Get group name = '%s' failed" %(group.name)
+        except:
+            print "Exception: %s" %(traceback.format_exc())
 
 def main(argv):
     if len(sys.argv) > 1:
@@ -76,10 +59,7 @@ def main(argv):
     django.setup()
     idps = get_idps_from_metadata(cache_path)
     for idp in idps:
-        try:
-            get_or_create_idp(entityID=idp['entityID'],name=idp['name'])
-        except:
-           pass
+        get_or_create_idp(entityID=idp['entityID'],name=idp['name'])
 
 if __name__ == '__main__':
     main(sys.argv[1:])