变量没有得到值

wskty 2008-11-09 12:36:07
bool t5 = ad.createUserAccount("OU=te33fd,DC=wskty,DC=net","wskty", "wskandwsk", "临","时的","2010-12-12");

public bool createUserAccount(string parentOUDN, string samName, string userPassword, string firstName, string lastName,string aed)
{

{//samName=loginname,
DateTime ldl = DateTime.Parse(aed);
string connectionPrefix = "LDAP://" + parentOUDN;
值已经传过来了,parentOUDN也有值了,但是connectionPrefix却为空,怎么回事呢?
DirectoryEntry de = new DirectoryEntry(connectionPrefix,"wsk643","P@ssw0rd" );
DirectoryEntry newUser = de.Children.Add("CN=" + firstName + " " + lastName, "user");
newUser.Properties["samAccountName"].Value = samName;
newUser.Properties["userPrincipalName"].Value = samName;
newUser.Properties["sn"].Add(lastName);
newUser.Properties["name"].Value = firstName + " " + lastName;
newUser.Properties["displayName"].Value=firstName + lastName;
newUser.Properties["givenName"].Add(firstName);
newUser.Properties["userAccountControl"].Value = 0X10000 | 0X0200;//用户为启用状态
newUser.CommitChanges();
newUser.Invoke("SetPassword", new object[] { userPassword });
newUser.InvokeSet("AccountExpirationDate", new object[] { ldl});// 用户到期时间
newUser.CommitChanges();
de.Close();
newUser.Close();
return true;
}
...全文
73 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wskty 2008-11-10
  • 打赏
  • 举报
回复
哪个高手给解释解释啊?
浮生若梦丶 2008-11-09
  • 打赏
  • 举报
回复
设断点调试下
DeltaCat 2008-11-09
  • 打赏
  • 举报
回复
看的写法, 是没问题的啊

代码也很简单, 估计问题不在这里吧, 你DEBUG 一下,看看呢
wskty 2008-11-09
  • 打赏
  • 举报
回复
我就是加断点调试知道那个没有得到值的.以前也可以运行的.现在却不行了...唉...
killer_liqiao 2008-11-09
  • 打赏
  • 举报
回复
up
hao1hao2hao3 2008-11-09
  • 打赏
  • 举报
回复
是不是转义字符的原因,试试 string connectionPrefix = @"LDAP://" + parentOUDN;
就是加个@。
wuyq11 2008-11-09
  • 打赏
  • 举报
回复
代码没问题。只能调试看看parentOUDN

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧