View Single Post
  #2 (permalink)  
Old 07-23-2007, 08:45 AM
ncushing ncushing is offline
Administrator
 
Join Date: Mar 2007
Location: Prezza Technologies
Posts: 187
Default

Shane,

Based on the error you are seeing, you are calling the correct methods. This is an issue with the 4.2 developer's kit that we have resolved in 4.3. To work around this, you'll need to wait for 4.3 which will be available early next month, or run your code in the context of a web application with session state available.

Currently, when a user is authenticated, a token that identifies the user is stored in the session. This token also links the user to it's Principal, which includes identity, profile, and security information. The user group methods check for a logged-in principal, and if session state is not available no user token will be found, resulting in the error you see.

In 4.3, we changed the methods so that they accept the user principal as an argument rather than trying to look it up in the security cache.

The code below illustrates this.

Code:
using Checkbox.Users;
using Prezza.Framework.Security.Principal

ExtendedPrincipal principal = (ExtendedPrincipal)UserManager.AuthenticateUser("AUser", "APassword");

Group newGroup = Group.CreateGroup("A Group", "A Group Description");

newGroup.AddUser("User1");
newGroup.AddUser("User2");
newGroup.AddUser("User3");

//Current API
Group.Commit(newGroup);

//4.3 API
Group.Commit(newGroup, principal);
Reply With Quote