private void LoadConfig()
{
ADPATH = System.Configuration.ConfigurationManager.AppSettings["LDAPPath"].ToString();
ADUSER = System.Configuration.ConfigurationManager.AppSettings["LDAPUser"].ToString();
ADPWD = System.Configuration.ConfigurationManager.AppSettings["LDAPPassword"].ToString();
det = new DirectoryEntry(ADPATH, ADUSER, ADPWD, AuthenticationTypes.Secure); } private void Seach()
{
try
{
DirectorySearcher ds = new DirectorySearcher(det);
ds.Filter = "(&(objectClass=user)(mail=" + tbxUserName.Text + "))";
SearchResult results = ds.FindOne();
if (results != null)
{
DirectoryEntry user = results.GetDirectoryEntry();
//[email protected]
user.Properties["mail"][0] = "[email protected]"; //我在这里修改了Email
//这里显示的也是修改过得,可是当我屏蔽上面的代码,再次查询的时候Email还是未修改过得Email
MessageBox.Show(user.Properties["mail"][0].ToString());
det.CommitChanges();
det.Close();
user.Close();
}
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
}
{
ADPATH = System.Configuration.ConfigurationManager.AppSettings["LDAPPath"].ToString();
ADUSER = System.Configuration.ConfigurationManager.AppSettings["LDAPUser"].ToString();
ADPWD = System.Configuration.ConfigurationManager.AppSettings["LDAPPassword"].ToString();
det = new DirectoryEntry(ADPATH, ADUSER, ADPWD, AuthenticationTypes.Secure); } private void Seach()
{
try
{
DirectorySearcher ds = new DirectorySearcher(det);
ds.Filter = "(&(objectClass=user)(mail=" + tbxUserName.Text + "))";
SearchResult results = ds.FindOne();
if (results != null)
{
DirectoryEntry user = results.GetDirectoryEntry();
//[email protected]
user.Properties["mail"][0] = "[email protected]"; //我在这里修改了Email
//这里显示的也是修改过得,可是当我屏蔽上面的代码,再次查询的时候Email还是未修改过得Email
MessageBox.Show(user.Properties["mail"][0].ToString());
det.CommitChanges();
det.Close();
user.Close();
}
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
}
偶素个AD二次开发初学者,想问问System.Configuration.ConfigurationManager.AppSettings["LDAPPath"]和["LDAPUser"] 、["LDAPPassword"] 这三个值是不是要在web.config设置<add key="" value="">才能获取相应的值,因为偶装了两台虚拟机 一台是AD+SQL 一台是sharepoint,如果不在web.config设置的话,那三个值获得的是null,会导致错误异常...