I am trying to troubleshoot a problem with a custom portal website that uses the ASP.NET membership and role providers and Active Directory along with the SQL profile provider. When users log in for the very first time, they are sometimes required to change
their passwords. That is working as desired, but when the ChangePassword method is called, a folder for the current user is somehow being created (in C:\Users on the server) and populated with some (mostly empty) folders.
Can anyone shed light on why the user folders are being created and how to prevent it?
Do you have any code that will create folders in your project ? I check ChangePassword method, it will update the password for the membership user in the membership data store.Theoretically, it will not create folder when you call this method. Please check
your code first.
Best Regards,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
Thank you. I did check my code, and it does nothing to create a folder directly. I feel like this is happening in the "black box" of the provider code for profile, membership, role, or role. Perhaps there is an application setting that needs to be present
or different in order to prevent what appears to be automatic creation of the user folders. Is this because when a user changes a password the user is somehow seen as having logged on locally?
I am trying the debugging approach, but I am not finding anything helpful just by selecting "Start Debugging" from the Debug menu in VS 2010. Can you walk me through exactly how I should do the debugging? Do I need to create breakpoints (and where) and/or
set debugging options a particular way? About all I can see happening now is that external code is being called when the ChangePassword method is called. I suspect it is that external code that might be creating the directory directly or indirectly, but the
code itself does not appear to be available to me.
I am currently looking at http://stackoverflow.com/questions/1883165/strange-issue-with-system-directoryservices-accountmanagement-userprincipal-find. We have also noticed an apparent memory leak with this application. I am looking into whether we can get
away from use of the userprincipal class and see if both problems go away.
Sadly, I could not get the other approach to work.
The following code failed with a "incorrect user name or password" error. I wonder if it is because the "user must change password" attribute is on for the users.
DirectoryEntry oDE;
oDE = new DirectoryEntry(myDomainSpec, myUserSpec, myStoredPassword, AuthenticationTypes.Secure);
oDE.Invoke("ChangePassword", new object[] { myStoredPassword, ChangeUserPassword.NewPassword });
oDE.CommitChanges();
oDE.Dispose();
...so I am back to using the following code, which still creates the undesired folders (and leaks memory, I suspect).
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, strDomainSpec))
{
var test = UserPrincipal.FindByIdentity(context, IdentityType.UserPrincipalName, User.Identity.Name.ToString());
test.ChangePassword(Session["lastsuccessfulpassword"].ToString(), ChangeUserPassword.NewPassword);
test.Dispose();
context.Dispose();
}
Note: If I comment out the test.ChangePassword(.... line, the user folder is not created (nor is the password changed, of course).
var test = UserPrincipal.FindByIdentity(context, IdentityType.UserPrincipalName, User.Identity.Name.ToString());
should return null as to pass username/identityname to FindByIdentity type needs to be 'IdentityType.SamAccountName' assuming User.Identity is logged in windows user identity.
It is also advised to test the code with different domain.
if you could give us the working part code, we will try to reproduce the problem at our end and confirm the behaviour
a_BobNelson
0 Points
7 Posts
ASP.NET membership provider and role provider with SQL profile provider - Automatic and undesired...
Jan 10, 2013 11:01 PM|LINK
I am trying to troubleshoot a problem with a custom portal website that uses the ASP.NET membership and role providers and Active Directory along with the SQL profile provider. When users log in for the very first time, they are sometimes required to change their passwords. That is working as desired, but when the ChangePassword method is called, a folder for the current user is somehow being created (in C:\Users on the server) and populated with some (mostly empty) folders.
Can anyone shed light on why the user folders are being created and how to prevent it?
Thank you,
Bob
Chen Yu - MS...
All-Star
21600 Points
2493 Posts
Microsoft
Re: ASP.NET membership provider and role provider with SQL profile provider - Automatic and undes...
Jan 14, 2013 09:08 AM|LINK
Hi,
Do you have any code that will create folders in your project ? I check ChangePassword method, it will update the password for the membership user in the membership data store.Theoretically, it will not create folder when you call this method. Please check your code first.
Best Regards,
Feedback to us
Develop and promote your apps in Windows Store
a_BobNelson
0 Points
7 Posts
Re: ASP.NET membership provider and role provider with SQL profile provider - Automatic and undes...
Jan 14, 2013 04:50 PM|LINK
Thank you. I did check my code, and it does nothing to create a folder directly. I feel like this is happening in the "black box" of the provider code for profile, membership, role, or role. Perhaps there is an application setting that needs to be present or different in order to prevent what appears to be automatic creation of the user folders. Is this because when a user changes a password the user is somehow seen as having logged on locally?
Bob
Chen Yu - MS...
All-Star
21600 Points
2493 Posts
Microsoft
Re: ASP.NET membership provider and role provider with SQL profile provider - Automatic and undes...
Jan 15, 2013 04:27 AM|LINK
Hi,
Have you tried to debug that part code to find the code that created the folder ? If not, please try it and tell us the result. Thanks a lot,
Best Regards,
Feedback to us
Develop and promote your apps in Windows Store
a_BobNelson
0 Points
7 Posts
Re: ASP.NET membership provider and role provider with SQL profile provider - Automatic and undes...
Jan 15, 2013 08:52 PM|LINK
I am trying the debugging approach, but I am not finding anything helpful just by selecting "Start Debugging" from the Debug menu in VS 2010. Can you walk me through exactly how I should do the debugging? Do I need to create breakpoints (and where) and/or set debugging options a particular way? About all I can see happening now is that external code is being called when the ChangePassword method is called. I suspect it is that external code that might be creating the directory directly or indirectly, but the code itself does not appear to be available to me.
Thank you for your continued help with this.
a_BobNelson
0 Points
7 Posts
Re: ASP.NET membership provider and role provider with SQL profile provider - Automatic and undes...
Jan 15, 2013 09:42 PM|LINK
I am currently looking at http://stackoverflow.com/questions/1883165/strange-issue-with-system-directoryservices-accountmanagement-userprincipal-find. We have also noticed an apparent memory leak with this application. I am looking into whether we can get away from use of the userprincipal class and see if both problems go away.
a_BobNelson
0 Points
7 Posts
Re: ASP.NET membership provider and role provider with SQL profile provider - Automatic and undes...
Jan 16, 2013 06:38 PM|LINK
Sadly, I could not get the other approach to work.
The following code failed with a "incorrect user name or password" error. I wonder if it is because the "user must change password" attribute is on for the users.
DirectoryEntry oDE;
oDE = new DirectoryEntry(myDomainSpec, myUserSpec, myStoredPassword, AuthenticationTypes.Secure);
oDE.Invoke("ChangePassword", new object[] { myStoredPassword, ChangeUserPassword.NewPassword });
oDE.CommitChanges();
oDE.Dispose();
...so I am back to using the following code, which still creates the undesired folders (and leaks memory, I suspect).
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, strDomainSpec))
{
var test = UserPrincipal.FindByIdentity(context, IdentityType.UserPrincipalName, User.Identity.Name.ToString());
test.ChangePassword(Session["lastsuccessfulpassword"].ToString(), ChangeUserPassword.NewPassword);
test.Dispose();
context.Dispose();
}
Note: If I comment out the test.ChangePassword(.... line, the user folder is not created (nor is the password changed, of course).
Any help greatly appreciated!
Chen Yu - MS...
All-Star
21600 Points
2493 Posts
Microsoft
Re: ASP.NET membership provider and role provider with SQL profile provider - Automatic and undes...
Jan 17, 2013 09:21 AM|LINK
Hi,
I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.
Best Regards,
Feedback to us
Develop and promote your apps in Windows Store
a_BobNelson
0 Points
7 Posts
Re: ASP.NET membership provider and role provider with SQL profile provider - Automatic and undes...
Jan 23, 2013 10:39 PM|LINK
Thank you. I appreciate your help and am hopeful that you can find someone to assist with this problem.
Parashuram
Member
98 Points
39 Posts
Re: ASP.NET membership provider and role provider with SQL profile provider - Automatic and undes...
Feb 08, 2013 06:53 PM|LINK
Following line of code
var test = UserPrincipal.FindByIdentity(context, IdentityType.UserPrincipalName, User.Identity.Name.ToString());
should return null as to pass username/identityname to FindByIdentity type needs to be 'IdentityType.SamAccountName' assuming User.Identity is logged in windows user identity.
It is also advised to test the code with different domain.
if you could give us the working part code, we will try to reproduce the problem at our end and confirm the behaviour