Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8905

Having an issue with inserting custom table item from a custom Event handler

$
0
0
I am having an issue that I hope someone can help me with. We are using Kentico 12 sp with windows authentication. We have a need to log when a user who belongs to a specific role authenticates. I created a custom event handler for SecurityEvents.Authenticate.Execute. if (e.User.IsInRole(@bsi-sfr-lg-hcwp_patientroster@, @Internal@) || e.User.SiteIndependentPrivilegeLevel.Equals(UserPrivilegeLevelEnum.GlobalAdmin)) { string EIN = e.User.UserName.Substring(4, 6); U.SamAccountName = EIN; PrincipalSearcher searcher = new PrincipalSearcher(U); UserPrincipal principal = (UserPrincipal)searcher.FindOne(); if (principal != null) { Login = principal.DisplayName; } else { Login = @Error getting Name@; } DataClassInfo classInfo = DataClassInfoProvider.GetDataClassInfo(AuthenticationLogTable); if (classInfo != null) { CustomTableItem NewAuthLog = new CustomTableItem(AuthenticationLogTable); NewAuthLog.SetValue(@Login@, e.User.UserName); NewAuthLog.SetValue(@DisplayName@, Login); if (e.User.SiteIndependentPrivilegeLevel.Equals(UserPrivilegeLevelEnum.GlobalAdmin)) NewAuthLog.SetValue(@UserRole@, @Global Admin@); else if (e.User.IsInRole(@bsi-sfr-lg-hcwp_patientroster@, @Internal@)) NewAuthLog.SetValue(@UserRole@, @bsi-sfr-lg-hcwp_patientroster@); // Add additional roles here as an else if NewAuthLog.Insert(); } } When it gets to the NewAuthLog.Insert I get the errorDescription:at CMS.CustomTables.CustomTableItem.InsertData() at CMS.DataEngine.AbstractInfoProvider`3.SetInfo(TInfo info) at CustomAuthenticationHandler.OnAuthentication(Object sender, AuthenticationEventArgs e) in C:\Sites\internal-test.vitalant.org\server\CMS\App_Code\_CustomHandlers\CustomAuthenticationHandler.cs:line 68 I did add an LogEvent entry before trying to insert the record by getting the various fields in the NewAuthLog and they populated the description in the event log Like I expected.

Viewing all articles
Browse latest Browse all 8905

Trending Articles