我正在编写一个软件,它可以让我添加用户并在 Windows Server 2008 R2上的活动目录中修改他们
我用了
using System.DirectoryServices.AccountManagement;
[DirectoryRdnPrefix("CN")]
[DirectoryObjectClass("Person")]
public class UserPrincipalEx : UserPrincipal
{
// Implement the constructor using the base class constructor.
public UserPrincipalEx(PrincipalContext context)
: base(context)
{ }
// Implement the constructor with initialization parameters.
public UserPrincipalEx(PrincipalContext context,
string samAccountName,
string password,
bool enabled)
: base(context, samAccountName, password, enabled)
{ }
// Create the "TermSrvProfilePath" property.
[DirectoryProperty("msTSProfilePath")]
public string TermSrvProfilePath
{
get
{
if (ExtensionGet("msTSProfilePath").Length != 1)
return "vide";
return (string)ExtensionGet("msTSProfilePath")[0];
}
set { ExtensionSet("msTSProfilePath", value); }
}
public static new UserPrincipalEx FindByIdentity(PrincipalContext context,
string identityValue)
{
return (UserPrincipalEx)FindByIdentityWithType(context,
typeof(UserPrincipalEx),
identityValue);
}
[DirectoryProperty("wWWHomePage")]
public string wWWHomePage
{
get
{
if (ExtensionGet("wWWHomePage").Length != 1)
return null;
return (string)ExtensionGet("wWWHomePage")[0];
}
set { this.ExtensionSet("wWWHomePage", value); }
}
}
那么,结果是什么?
我成功读取了wWWHomePage属性,但是当我尝试获取时它是空的:TermSrvProfilePath ....
我不明白,我完全迷路了!