July 27, 2015 at 4:02 pm
I am working on a Script task that pulls AD info to a SQl table. So far many attribures I pulled from AD work fine.
But for PASSWD_CANT_CHANGE attribute in UserAccessControl, I always get the value of 0 meaning false. Help please
bool CannotChangePassword = false;
const int UF_PASSWD_CANT_CHANGE = 0x0040;
if (Convert.ToBoolean(flags & UF_PASSWD_CANT_CHANGE))
{
CannotChangePassword = true; // cannot get to here
}
else
{
CannotChangePassword = false; //always return false
}
Thanks
July 29, 2015 at 6:44 am
Hi,
Could you try to debug and see what integer value you get in flags for PASSWD_CANT_CHANGE. Also, try to declare int32 instead of int.
Regards,
Vijay
July 29, 2015 at 2:59 pm
I am trying use the first part of the code as solution,
but found out com object does not work well in SSIS code.
http://devblog.rayonnant.net/2011/04/ad-net-toggle-users-cant-change.html
Any way to convert the code and avoid using activeds reference?
Thanks
July 29, 2015 at 3:02 pm
or use windows provider: this is the vb code,
could you help to convert it to c# code?
Const ADS_UF_PASSWD_CANT_CHANGE = &H40
Function UserCannotChangePassword(strDomain As String, strUser As String, strUserCred As String, strPassword As String) As Boolean
UserCannotChangePassword = False
Dim oUser As IADs
strPath = "WinNT://" + strDomain + "/" + strUser
If "" <> strUserCred Then
Dim dso As IADsOpenDSObject
' Bind to the group with the specified user name and password.
Set dso = GetObject("WinNT:")
Set oUser = dso.OpenDSObject(strPath, strUserCred, strPassword, 1)
Else
' Bind to the group with the current credentials.
Set oUser = GetObject(strPath)
End If
If (oUser.Get("userFlags") And ADS_UF_PASSWD_CANT_CHANGE) <> 0 Then
UserCannotChangePassword = True
Else
UserCannotChangePassword = False
End If
End Function
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy