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