Sitecore 7.1: Error getting userName pragmatically


I have added Sitecore Active Directory Module and I have 2 user with the same name in both domains e.g.

Login with the AD user with login name ad\john.doe works, the other (sitecore) doesn't and after 2 logins this error came up! As a workaround is use the AD user now.

Does someone know how to resolve?

Error Message: userName

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.InvalidOperationException: userName

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: userName] Sitecore.Caching.UserProfile.UserProfileCache.RemoveUser(String userName) +223 Sitecore.Caching.CacheManager.ClearSecurityCache(String userName) +32 [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +76 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +193 System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +35 Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume(PipelineArgs args, Pipeline pipeline) +398 Sitecore.Pipelines.Pipeline.Start(PipelineArgs args, Boolean atomic) +327 Sitecore.Pipelines.Pipeline.Start(String pipelineName, PipelineArgs args, Boolean atomic) +197 Sitecore.sitecore.login.LoginPage.Login_LoggingIn(Object sender, LoginCancelEventArgs e) +537 System.Web.UI.WebControls.Login.AttemptLogin() +108 System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +93 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +84 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804