饮酒买醉
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
::
9 随笔 :: 15 文章 :: 9 评论 :: 1 Trackbacks
在AD密码修改操作时报错:System.Runtime.InteropServices.COMException: The server is not operational 该服务器不可操作!
using
System.DirectoryServices;
try
{
string
sAMAccountName
=
"
xingtingting
"
;
string
newPassword
=
"
12345678
"
;
//
iw.local/OU=HXZ,
DirectoryEntry de
=
new
DirectoryEntry(
"
LDAP://iw.local/OU=HXZ,DC=iw,DC=local
"
,
"
iw\\spsadmin
"
,
"
iswind
"
,AuthenticationTypes.Sealing );
DirectorySearcher deSearch
=
new
DirectorySearcher(de);
deSearch.Filter
=
"
(&(&(objectCategory=person)(objectClass=user))(sAMAccountName=
"
+
sAMAccountName
+
"
))
"
;
deSearch.SearchScope
=
SearchScope.Subtree;
SearchResult result
=
deSearch.FindOne();
de
=
new
DirectoryEntry(result.Path);
de.Invoke(
"
SetPassword
"
,
new
object
[]
{newPassword}
);
de.CommitChanges();
de.Close();
System.Windows.Forms.MessageBox.Show(
"
修改成功!
"
);
}
catch
(Exception ex)
{
throw
ex;
}
执行至:
de.Invoke("SetPassword",new object []{newPassword});
抛异常。
在AD服务器上运行正常,但在加入域的服务器运行就出错。可以断定应该不是程序的问题,但找了很久也没找到解决办法。后来在
http://www.highdots.com/forums/asp-net-security/change-password-active-directory-webapplication-700434.html
看到一段话:
You may need to experiment with different variations on the dcDNS variable
and you may need to remove the ServerBind flag if you are using a NETBIOS
name. Also, you may need to remove the Sealing flag as well, but be warned
that in order to set or change passwords, some sort of encrypted channel
(SSL or Kerberos) must be available.
突然想到犯了一个低级错误!没有把DNS设置正确!!因为测试AD服务器也是DNS服务器,所以需要把AD服务器的地址配到本机的DNS中。配置后运行成功!
posted on 2006-01-07 12:08
饮酒买醉
阅读(1331)
评论(2)
编辑
收藏
评论
#1楼
2007-01-10 13:28
qu [未注册用户]
我想请问下您:
在 .net下实现一个用户验证的功能,现在老是出错,不知道是不是我LDAP连接字符串的问题,我的LDAP字符串是这样的,LDAP://jieludc.jielu.com.cn/cn=jielu,DC=jielu,DC=com,DC=cn
做活动目录服务器的是jieludc.jielu.com.cn,活动目录有一个组是jielu,里面有我要验证的用户,基本都在里面,ip地址是192.168.20.165 ,和我的dns地址是一样的。现在就是成功不了,出现操作错误,设定DirectoryEntry(results.Path,ADUser,ADPassword,AuthenticationTypes.Secure);还会出现登陆失败,未知的用户名和密码。出错的地方是这句 :SearchResult resEnt in mySearcher.FindAll())。 我不知道我的电脑,也就是运行的电脑在不在域jielu.com.cn中,怎么看。
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.DirectoryServices;
namespace AdLogin
{
/// <summary>
/// test 的摘要说明。
/// </summary>
public class test : System.Web.UI.Page
{
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
GetAllOU();
Console.ReadLine();
}
//获取目录中需要的组织单元(OU)
public static void GetAllOU()
{
DirectoryEntry entry = new DirectoryEntry("LDAP://jieludc.jielu.com.cn/DC=jielu,DC=com,DC=cn");
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=organizationalUnit)");
foreach(SearchResult resEnt in mySearcher.FindAll())
{
Console.Write(resEnt.GetDirectoryEntry().Name.ToString());
//Console.WriteLine("\t"resEnt.GetDirectoryEntry().Name.ToString());
}//end foreach
}//end GetAllOU
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
GetAllOU();
Console.ReadLine();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
回复
引用
#2楼
2008-07-27 08:11
mhgj [未注册用户]
ngfuhjfyjk564149849gkxhjdywuc btmvhfmj !@##$%$%^^&*&()_++)((*&^%$#@@!!!~~~?><:"""}}{{LLK::>?><MHGFDEWWWSDDFTRE!!@##$%%^%^&~&***(*(((~~~~~~~~~~~~
回复
引用
社区
新闻
新用户注册
刷新评论列表
标题
姓名
主页
Email
(只有博主才能看到)
验证码
*
看不清,换一张
[
登录
][
注册
]
内容(请不要发表任何与政治相关的内容)
Remember Me?
登录
使用高级评论
新用户注册
返回页首
恢复上次提交
[使用Ctrl+Enter键可以直接提交]
最新IT新闻:
·
微软投诉番茄花园幕后:两月前BSA代为出手
·
第一财经周刊:当前互联网世界正处无秩序时代
·
Visual Studio 2008 SDK 1.1 发布
·
死敌VMware变身微软认证计划新成员
·
英特尔雅虎开发网络计算机频道
博客园新闻频道
博客园首页
社区
<
2006年1月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的新闻
最新评论
我的标签
留言簿
(3)
给我留言
查看留言
我参与的团队
SharePoint团队(0/721)
上海.NET俱乐部(0/2200)
我的标签
Axapta
(3)
Excel
(1)
export
(1)
SQL database has issued an error
(1)
随笔档案
(8)
2008年7月 (2)
2008年6月 (2)
2006年2月 (1)
2006年1月 (3)
文章分类
(15)
Active Directory(1)
(rss)
ASP.NET(2)
(rss)
Axapta
(rss)
C#(3)
(rss)
IBM MQ(1)
(rss)
JavaScript(1)
(rss)
Share Point(2)
(rss)
Web Services
(rss)
其他收藏(4)
(rss)
设计模式
(rss)
数据库相关(1)
(rss)
牛人链
海东的技术资料
积分与排名
积分 - 5145
排名 - 4781
最新评论
1. re: AX中调用.Net的Dll时需要注意的几点。
@[徐风碧树]
有没有重起AX服务?
--饮酒买醉
2. re: 在AD密码修改操作时报错:System.Runtime.InteropServices.COMException: The server is not operational 该服务器不可操作!
ngfuhjfyjk564149849gkxhjdywuc btmvhfmj ...
--mhgj
3. re: AX中调用.Net的Dll时需要注意的几点。
你的意思是说,客户端不需要部署相应的dll文件就可以实现调用服务器端的dll吗?我刚才按照上面的步骤做了测试,客户端运行依然报错。
--[徐风碧树]
4. re: 安装vs.net与调试asp.net时遇到的常见问题(转)
未能将脚本调试器附加到计算机”××ד上的的进程“[3400] EXPLORE.EXE”。 发生了通常表示安装被损坏的错误(代码Ox80040155)。如若问题仍然存在,...
--村蝈蝈
阅读排行榜
1. 在AD密码修改操作时报错:System.Runtime.InteropServices.COMException: The server is not operational 该服务器不可操作!(1331)
2. 求助:单点登陆帐户密码修改的问题!!(425)
3. 新建AD用户后启用AD帐户(393)
4. 程序员要学会这么多语言吗?(97)
5. AX中调用.Net的Dll时需要注意的几点。(60)
评论排行榜
1. 新建AD用户后启用AD帐户(4)
2. 在AD密码修改操作时报错:System.Runtime.InteropServices.COMException: The server is not operational 该服务器不可操作!(2)
3. AX中调用.Net的Dll时需要注意的几点。(2)
4. Axapta "cannot select a record The SQL database has issued an error"(0)
5. 求助:单点登陆帐户密码修改的问题!!(0)
Powered by:
博客园
Copyright © 饮酒买醉