A
Andy Taslim
Guest
Hi there,
I know there are lots of similar questions around this. But, mine is a bit unique, because ADLDS works fine for "SetPassword", but not for "ChangePassword". It returned the below error.
A constraint violation occurred. (Exception from HRESULT: 0x8007202F)
My environment is SharePoint 2013 RTM with FBA connected to ADLDS - running under Windows Server 2012.
I have also ensure the below, but no luck.
1. Reset password without SSL Config snippets : ADLDS : Reset password without SSL | SK Tech Scratchpad
2. The app pool account is assigned in "CN=Administrators" role. In fact, as it is my development VM, I have only 1 user to run everything.
ChangePassword code
public void ChangeUserPassword(string sUserName, string sOldPassword, string sNewPassword, out string sMessage)
{
using (HostingEnvironment.Impersonate())
{
PrincipalContext oPrincipalContext = null;
UserPrincipal oUserPrincipal = null;
try
{
oPrincipalContext = new PrincipalContext(ContextType.ApplicationDirectory, sDomainAddress, sDefaultOU);
oUserPrincipal = UserPrincipal.FindByIdentity(oPrincipalContext, sUserName);
oUserPrincipal.ChangePassword(sOldPassword, sNewPassword);
sMessage = "";
}
catch (Exception ex)
{
if (ex.InnerException == null)
sMessage = ex.Message;
else
sMessage = ex.InnerException.Message;
}
finally
{
if (oUserPrincipal != null)
oUserPrincipal.Dispose();
if (oPrincipalContext != null)
oPrincipalContext.Dispose();
}
}
}
SetPassword code
public void SetUserPassword(string sUserName, string sNewPassword, out string sMessage)
{
using (HostingEnvironment.Impersonate())
{
PrincipalContext oPrincipalContext = null;
UserPrincipal oUserPrincipal = null;
try
{
oPrincipalContext = new PrincipalContext(ContextType.ApplicationDirectory, sDomainAddress, sDefaultOU);
oUserPrincipal = UserPrincipal.FindByIdentity(oPrincipalContext, sUserName);
oUserPrincipal.SetPassword(sNewPassword);
sMessage = "";
}
catch (Exception ex)
{
if (ex.InnerException == null)
sMessage = ex.Message;
else
sMessage = ex.InnerException.Message;
}
finally
{
if (oUserPrincipal != null)
oUserPrincipal.Dispose();
if (oPrincipalContext != null)
oPrincipalContext.Dispose();
}
}
}
Have anyone faced similar issue before, or any guidance? Thank you.
Continue reading...
I know there are lots of similar questions around this. But, mine is a bit unique, because ADLDS works fine for "SetPassword", but not for "ChangePassword". It returned the below error.
A constraint violation occurred. (Exception from HRESULT: 0x8007202F)
My environment is SharePoint 2013 RTM with FBA connected to ADLDS - running under Windows Server 2012.
I have also ensure the below, but no luck.
1. Reset password without SSL Config snippets : ADLDS : Reset password without SSL | SK Tech Scratchpad
2. The app pool account is assigned in "CN=Administrators" role. In fact, as it is my development VM, I have only 1 user to run everything.
ChangePassword code
public void ChangeUserPassword(string sUserName, string sOldPassword, string sNewPassword, out string sMessage)
{
using (HostingEnvironment.Impersonate())
{
PrincipalContext oPrincipalContext = null;
UserPrincipal oUserPrincipal = null;
try
{
oPrincipalContext = new PrincipalContext(ContextType.ApplicationDirectory, sDomainAddress, sDefaultOU);
oUserPrincipal = UserPrincipal.FindByIdentity(oPrincipalContext, sUserName);
oUserPrincipal.ChangePassword(sOldPassword, sNewPassword);
sMessage = "";
}
catch (Exception ex)
{
if (ex.InnerException == null)
sMessage = ex.Message;
else
sMessage = ex.InnerException.Message;
}
finally
{
if (oUserPrincipal != null)
oUserPrincipal.Dispose();
if (oPrincipalContext != null)
oPrincipalContext.Dispose();
}
}
}
SetPassword code
public void SetUserPassword(string sUserName, string sNewPassword, out string sMessage)
{
using (HostingEnvironment.Impersonate())
{
PrincipalContext oPrincipalContext = null;
UserPrincipal oUserPrincipal = null;
try
{
oPrincipalContext = new PrincipalContext(ContextType.ApplicationDirectory, sDomainAddress, sDefaultOU);
oUserPrincipal = UserPrincipal.FindByIdentity(oPrincipalContext, sUserName);
oUserPrincipal.SetPassword(sNewPassword);
sMessage = "";
}
catch (Exception ex)
{
if (ex.InnerException == null)
sMessage = ex.Message;
else
sMessage = ex.InnerException.Message;
}
finally
{
if (oUserPrincipal != null)
oUserPrincipal.Dispose();
if (oPrincipalContext != null)
oPrincipalContext.Dispose();
}
}
}
Have anyone faced similar issue before, or any guidance? Thank you.
Continue reading...