描述:
ActiveDriectory编程中,我添加了一个用户,得到了IADsUser接口pUser,如何将其设置第一次登陆必须修改密码??
开发环境:winXP, VC6
环境:Windows2000 advance Server,装了Active Driectory
我用了
CComBSTR sbstrProp;
CComVariant svar;
sbstrProp = "pwdLastSet";
svar = 0;
hr = padsUser->Put(sbstrProp, svar);
会返回0x8000500f错误!!
解决方案1:
Win32_UserAccount
The Win32_UserAccount WMI class contains information about a user account on a Windows operating system.
Note Because both the Name and Domain are key properties, enumerating Win32_UserAccount on a large network can affect performance negatively. Calling GetObject or querying for a specific instance has less impact.
The following syntax is simplified from Managed Object Format (MOF) code and includes all inherited properties.
class Win32_UserAccount : Win32_Account
{
uint32 AccountType;
string Caption;
string Description;
boolean Disabled;
string Domain;
string FullName;
datetime InstallDate;
boolean LocalAccount;
boolean Lockout;
string Name;
boolean PasswordChangeable;
boolean PasswordExpires;
boolean PasswordRequired;
string SID;
uint8 SIDType;
string Status;
};
Methods
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_useraccount.asp
http://msdn.microsoft.com/library/en-us/dnclinic/html/scripting01132004.asp
http://msdn.microsoft.com/msdnmag/issues/0500/wmiprov/
If this value is set to 0 and the User-Account-Control attribute does not contain the UF_DONT_EXPIRE_PASSWD flag, then the user must set the password at the next logon.
我看MSDN上的示例也是这样的,是不是因为跟其他属性冲突的缘故。
0x8000500FL E_ADS_SCHEMA_VIOLATION The attempted action violates the directory service schema rules