Developer forum

Forum » Development » Unable to log in with imported user, until i recycle app pool

Unable to log in with imported user, until i recycle app pool

Martin Nielsen
Reply

Hey,

 

I'm looking into a strange problem regarding Extranet login in DW.

 

I have a module that extracts a use from a Sharepoint solution and saves user information into the AccessUser table in DW.

At first glance everything seems to be okay, but when i try to log in with the user it fails.

 

The funny thing is, that if i recycle the app pool, then the login works, without running the import again.

 

Is the login method in DW dependent of some kind of cached collection that i need to clear/append to when i save a user to the database?

 

My website is running 8.2.1.8, if that makes any difference.

 

Hope someone can assist :-)

 

// Martin

 


Replies

 
Nicolai Høeg Pedersen
Reply

It should work without the recycle... Do you also import new groups and assign those to a page i.e.?

 

Or is it just the user added to an existing group?

 

BR Nicolai

 
Martin Nielsen
Reply
user = (from d in db.AccessUsers
                  where d.AccessUserUserName.Equals(AccessUserEmail)
                  select d).FirstOrDefault();
          if (user == null)
          {
            user = new AccessUser();
            user.AccessUserUserName = AccessUserEmail;
            db.AccessUsers.InsertOnSubmit(user);
            newUser = true;
          }
          else
          {
            if (!string.IsNullOrEmpty(user.AccessUserPassword) && !user.AccessUserPassword.Equals(AccessUserPassword))
            {
              passChanged = true;
            }
          }
          user.AccessUserGroups = string.Format("@{0}@", compId.ToString());
          user.AccessUserType = 5;
          user.AccessUserName = AccessUserName;
          user.AccessUserCountry = AccessUserCountry;
          user.AccessUserJobTitle = AccessUserJobTitle;
          user.AccessUserEmail = AccessUserEmail;
          user.AccessUserValidFrom = DateTime.Now.AddDays(-1);
          user.AccessUserValidTo = new DateTime(2999, 12, 31);

          user.AccessUserPassword = AccessUserPassword;
          user.AccessUserActive = true;
       
          db.SubmitChanges();
          //update dw cache
          if (newUser)
          {
            User u = User.GetUserByID(user.AccessUserID);
            u.Save();
          }
 
Martin Nielsen
Reply

This is my code.

 
Morten Snedker
Reply

Hi Martin,

 

Which namespace are you using for the AccessUser? You should be using

Dynamicweb.Modules.UserManagement.User user = new Dynamicweb.Modules.UserManagement.User();

Is that the case?

 

Regards /Snedker

 
Martin Nielsen
Reply

First the user is created in DB with LINQ.

 

And after that we find the user via User u = User.GetUserByID(user.AccessUserID); ,which is from the Dynamicweb.Modules.UserManagement namespace, and save the user, to try and get DW to recognize the user without a recycle, but that doesn't work.

 
Martin Nielsen
Reply

I think i found out what the problem might be, but i don't know how to fix it.

 

My structure in the User Management looks like this:

 

Extranet (Group)

- Co3 (Group)

-- Co3User (User)

- Another customer (Group)

-- AnotherLogin (User)

 

When ia user i create the group AND the user, which means that there might be some caching on the protected pages, that don't know about my newly created group.

 

On my pages that i protected with login, i have only selected the top Extranet group "Extranet", not all the children.

So maybe the childgroups to "Extranet" is cached somewhere on the pages in DW?

 

I cannot explain this problem if it's not a caching or sessions issue, since recycling fixes everything.

 

// Martin

 

 

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

It is because you create the Groups also

 

In your //Update dw cache line, call this line:

 

Dynamicweb.Frontend.Reset.ResetHash(Frontend.Reset.HashType.AreaAndPage);

Votes for this answer: 1

 

You must be logged in to post in the forum