Ldap logout throws errors

Posted by Community Admin on 03-Aug-2018 15:19

Ldap logout throws errors

All Replies

Posted by Community Admin on 22-Nov-2010 00:00

When using the ldap security, if i click logout i get an error. I don't get it if I'm using the default provider. I didn't have the problem in the beta just the RC.

Posted by Community Admin on 24-Nov-2010 00:00

Hello kz,

Thank you for using our services.

This is a know issue, which we have identified in the RC. It is logged for fixing, however I can not give you a time frame for the fix.

All the best,
Radoslav Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-Nov-2010 00:00

Greetings,


I've getting an error while attempting to logout a user controlled by my custom membership provider.


Server Error in '/TestSite' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

Line 83:         protected void ButtonLogoutClick(object sender, EventArgs e)
Line 84:         
Line 85:             SecurityManager.Logout();
Line 86: 
Line 87:             SystemManager.CurrentHttpContext.Response.Redirect(homePageUrl);

Source File: C:\DevProjects\TestSite\Main\Source\Website\Source\Website.Widgets\LoginLogoutLink\LoginLogoutLink.cs    Line: 85 

Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]
   DynamicModule.ns.Wrapped_TestSiteMembershipDataProvider_78a90133a55d4c5d9ff707281211c266.Clone() +418
   Telerik.Sitefinity.Data.ManagerBase`1.SetProvider(String providerName, String transactionName) +454

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType) +0
   System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +517
   Telerik.Sitefinity.Data.ManagerBase`1.GetManager(String providerName, String transactionName) +753
   Telerik.Sitefinity.Security.SecurityManager.LogoutImpl(String providerName, Guid userId, String userName, Credentials credentials) +84
   Telerik.Sitefinity.Security.SecurityManager.Logout() +535
   TestSite.Widgets.LoginLogoutLink.ButtonLogoutClick(Object sender, EventArgs e) in C:\DevProjects\TestSite\Main\Source\Website\Source\Website.Widgets\LoginLogoutLink\LoginLogoutLink.cs:85
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691


This was working correctly on the BETA and BETA 2 version. Is it the same error that's happening with the Ldap authentication mechanism?

Posted by Community Admin on 25-Nov-2010 00:00

Hello Daniel,

Thank you for joining the conversation.

When logging out with your control can you please double check if the Security manager is instantiated with your custom provider. From the stack trace it seems that the Security manager is executing for the default provider, and if your user does not exist there you will get a null reference exception.

All the best,
Radoslav Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 25-Nov-2010 00:00

Hello Rodaslov,


Everything was working on the BETA version and I haven't actually changed anything on the Providers when switching to the RC version.

Please note that this also happens if I head over to http://mysite/sitefinity and when it says my user doesn't have privileges to access the back office and I press the switch user, meaning the default sitefinity login control also doesn't currently log me out of the system, it throws the same error, so something must have changed in the latest RC version concerning the wrappers or something alike for it to have stopped working.

I'm attaching my MembershipDataProvider wrapper and also my Provider configuration and login / logout calls. If you can, please check out if something ain't how it's supposed to be, although it was in fact working on the previous version like this.

SecurityConfig.config
<roleProviders>
        <add description="TestSite Custom Role Data Provider" resourceClassId="" type="TestSite.Website.Core.TestSiteRoleDataProvider" type:type="System.RuntimeType, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" applicationName="TestSite/" enabled="True" name="TestSite" />
    </roleProviders>
    <membershipProviders>
        <add description="TestSite Custom Membership Data Provider" resourceClassId="" type="TestSite.Website.Core.TestSiteMembershipDataProvider" type:type="System.RuntimeType, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" applicationName="TestSite/" enabled="True" name="TestSite" />
    </membershipProviders>

TestSiteMembershipDataProvider
public class DocnectionMembershipDataProvider : MembershipDataProvider
    public override User CreateUser(string userName) throw new NotImplementedException();
 
    public override User CreateUser(Guid id, string userName) throw new NotImplementedException();
 
    public override User GetUser(Guid id)
    
        using (var ctx = ConfigMgr.Instance.ORMContextFactory.CreateORMContext())
        
            var user = new User();
 
            var userEntity = new UserEntity
                                 
                                     UserKey = id
                                 ;
 
            if (ctx.Adapter.FetchEntityUsingUniqueConstraint(userEntity, userEntity.ConstructFilterForUCUserKey()))
            
                user.ApplicationName = "TestSite/";
                user.Id = userEntity.UserKey;
                user.FirstName = userEntity.FirstName;
                user.LastName = userEntity.LastName;
                user.Email = userEntity.Email;
 
                user.SetCreationDate(userEntity.CreationDate);
                user.SetUserName(userEntity.Username);
 
                user.ManagerInfo = new ManagerInfo
                                       
                                           ProviderName = "TestSite",
                                           ApplicationName = "TestSite/"
                                       ;
            
 
            return user;
        
    
 
    public override IQueryable<User> GetUsers() // Code Removed
 
    public override void Delete(User item) // Code Removed
 
    public override bool ValidateUser(Guid userId, string password) // Code Removed
 
    public override bool ValidateUser(string userName, string password) // Code Removed
 
    public override bool ValidateUser(User user, string password) return ValidateUser(user.Id, password);
 
    public override void RollbackTransaction()
    
        // Empty but I had it empty also on the BETA version
    
 
    public override void FlushTransaction()
      
        // Empty but I had it empty also on the BETA version
    
 
    protected override object CreateNewTransaction(string transactionName)
    
        return null;
    
 
    protected override object GetTransaction()
    
        return null;
    
 
    public override void CommitTransaction()
    
        // Empty but I had it empty also on the BETA version
    

Login
var userManager = UserManager.GetManager("TestSite");
 
userManager.Provider.SuppressSecurityChecks = true;
 
if (!userManager.ValidateUser(TextBoxUsername.Text, TextBoxPassword.Text))
     if (LabelIncorrectCredentials != null)
     
          LabelIncorrectCredentials.Visible = true;
     
 
      return;
 
var user = userManager.GetUser(TextBoxUsername.Text);
 
SecurityManager.SetAuthenticationCookie(SystemManager.CurrentHttpContext.Response, "TestSite", TextBoxUsername.Text, CheckBoxRememberMe != null ? CheckBoxRememberMe.Checked : false);

Logout
SecurityManager.Logout();
 
SystemManager.CurrentHttpContext.Response.Redirect(homePageUrl);

Thanks in advance!

Regards,
Daniel

Posted by Community Admin on 01-Dec-2010 00:00

Hello Daniel,

Thank you for providing all the needed information.

The problem which you are experiencing is not related to the LDAP provider bug. Since your membership provider is inheriting from the MembershipDataProvider class you need to implement an interface for the IOpenAccessDataProvider interface. This is so because the MembershipDataProvider class is meant to work with OpenAccess for data persistence.

Greetings,
Radoslav Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 02-Dec-2010 00:00

Greetings,


Inheriting from the OpenAccessMembershipProvider solved my issue, thank you very much!

Regards,
Daniel

This thread is closed