LDAP服务器是安装在Windows Server2003上的Sun Java System Directory Server 5.2
测试客户端操作系统Windows XP SP2,开发环境vs2005 C#以下代码是根据MSDN的范例稍做修改而成:
try
{
// Bind to the Users container, add a new group and a new contact.
//DirectoryEntry de = new DirectoryEntry("LDAP://CN=Users,DC=fabrikam,DC=com");
DirectoryEntry de = new DirectoryEntry(
"LDAP://192.168.0.223:14614/CN=Users, DC=example, DC=com",
"cn=Directory Manager", "12345678",
AuthenticationTypes.ServerBind | AuthenticationTypes.FastBind); // Create a new group object in the local cache.
DirectoryEntry newGroup = de.Children.Add("CN=Sales", "group"); // Active Directory requires the sAMAccountName property for all
// Security Principal objects beginning with Windows Server 2003
// servers, the sAMAccountName will automatically be generated when
// Commit() is called if no sAMAccountName is provided.
newGroup.Properties["sAMAccountName"].Value = "Sales";
// Save the new object to the server.
newGroup.CommitChanges(); // Create and add a new contact object.
DirectoryEntry newContact = de.Children.Add("CN=New Contact", "inetOrgPerson");
newContact.Properties["sAMAccountName"].Value = "New Contact";
newContact.CommitChanges();
}
catch (COMException COMEx)
{
// If a COMException is thrown, then the following code example can catch the text of the error.
// For more information about handling COM exceptions, see Handling Errors.
Console.WriteLine(COMEx.ErrorCode);
Console.WriteLine(COMEx.Message);
}错误信息如下:
-2147016684
该请求的操作没有满足一个或多个与该对象的类别相关的约束。 (异常来自 HRESULT:0x80072014)请高手指教,到底是什么问题?多谢!
---------------------------------------------------
另外,我还发了个帖子在别的版块,同样的问题:
http://topic.csdn.net/u/20080611/16/9802a57b-6e35-46a3-981d-b23226fe0b0e.html
测试客户端操作系统Windows XP SP2,开发环境vs2005 C#以下代码是根据MSDN的范例稍做修改而成:
try
{
// Bind to the Users container, add a new group and a new contact.
//DirectoryEntry de = new DirectoryEntry("LDAP://CN=Users,DC=fabrikam,DC=com");
DirectoryEntry de = new DirectoryEntry(
"LDAP://192.168.0.223:14614/CN=Users, DC=example, DC=com",
"cn=Directory Manager", "12345678",
AuthenticationTypes.ServerBind | AuthenticationTypes.FastBind); // Create a new group object in the local cache.
DirectoryEntry newGroup = de.Children.Add("CN=Sales", "group"); // Active Directory requires the sAMAccountName property for all
// Security Principal objects beginning with Windows Server 2003
// servers, the sAMAccountName will automatically be generated when
// Commit() is called if no sAMAccountName is provided.
newGroup.Properties["sAMAccountName"].Value = "Sales";
// Save the new object to the server.
newGroup.CommitChanges(); // Create and add a new contact object.
DirectoryEntry newContact = de.Children.Add("CN=New Contact", "inetOrgPerson");
newContact.Properties["sAMAccountName"].Value = "New Contact";
newContact.CommitChanges();
}
catch (COMException COMEx)
{
// If a COMException is thrown, then the following code example can catch the text of the error.
// For more information about handling COM exceptions, see Handling Errors.
Console.WriteLine(COMEx.ErrorCode);
Console.WriteLine(COMEx.Message);
}错误信息如下:
-2147016684
该请求的操作没有满足一个或多个与该对象的类别相关的约束。 (异常来自 HRESULT:0x80072014)请高手指教,到底是什么问题?多谢!
---------------------------------------------------
另外,我还发了个帖子在别的版块,同样的问题:
http://topic.csdn.net/u/20080611/16/9802a57b-6e35-46a3-981d-b23226fe0b0e.html
解决方案 »
- <script language="javascript" type="text/javascript" src="E:\company\My97DatePic
- 求项目成本核算的文档一份
- 急急急这是个什么,using Fjeptri.DataAccess.DataHelper;
- 关于数据库备份
- 大家一起学习Composite UI Application Block! 强烈要求增加一个Smart Client或者CAB的板块
- datagrid中的数据汇总,小弟是菜鸟希望师兄们帮忙
- 虚心请教关于组件的定义,组件的用途,组件的开发
- 写了一个windows 服务,有的机器上可以运行,我们的服务器上不能运行,详情请进!
- 问一个数据库写回问题
- 刚学c#,有个小问题,请大家帮帮忙,谢谢!
- 编写windows程序 从Exchange Server 读取邮件的问题!
- c#中monthcalendar的值怎么获取?是用属性,方法?
没弄过这个,学习一下