2013-04-12 39 views
4

我想使用UnboundID LDAP SDK將組添加到我的Active Directory服務,並且不斷收到錯誤503:不會執行。使用UnboundID添加組條目時不會執行錯誤503

我已驗證我正在使用SSL連接,並且正在與屬於管理員組的用戶進行連接,該用戶無論我是否誤會,都會爲他創建新條目提供權利。

我也將LDAP接口事件的日誌記錄級別一直提高到5,而事件查看器記錄了大量事件,其中沒有一個用於解釋爲什麼服務不願意執行我的創建條目操作。

有什麼可以導致這個問題的想法嗎?

下面是我使用的Scala代碼的樣本:

val connection = connect("MyAdminUser", "MyAdminPass") 

val addGroupResult = connection.add("CN=TestGroup2,OU=Groups,OU=mydomain,DC=mydomain,DC=local", 
    new Attribute("objectClass", "top", "group"), 
    new Attribute("name","TestGroup2"), 
    new Attribute("sAMAccountName","TestGroup2"), 
    new Attribute("sAMAccountType","268435456"), 
    new Attribute("objectCategory","CN=Group,CN=Schema,CN=Configuration,DC=mydomain,DC=local"), 
    new Attribute("cn","TestGroup2"), 
    new Attribute("distinguishedName","CN=TestGroup2,OU=Groups,OU=mydomain,DC=mydomain,DC=local"), 
    new Attribute("instanceType","4"), 
    new Attribute("groupType","-2147483646") 
    ) 

private def connect(user: String, pass: String) = { 
    val options = new LDAPConnectionOptions() 
    options.setFollowReferrals(true) 
    val sslUtil = new SSLUtil(new TrustAllTrustManager()) 
    val socketFactory = sslUtil.createSSLSocketFactory() 
    new LDAPConnection(socketFactory, options, host, securePort, DN(user), pass) 
} 

而這裏的錯誤消息,我得到:

Exception in thread "main" LDAPException(resultCode=53 (unwilling to perform), errorMessage='0000209A: SvcErr: DSID-031A104A, problem 5003 (WILL_NOT_PERFORM), data 0', diagnosticMessage='0000209A: SvcErr: DSID-031A104A, problem 5003 (WILL_NOT_PERFORM), data 0') 

回答

8

我的錯誤是,包括在過多屬性添加操作,其中一些操作不應該手動設置,而是由SAM(安全帳戶管理器)設置。

正確的代碼如下:

val addGroupResult = connection.add("CN=TestGroup2,OU=Groups,OU=simpleBI,DC=domain,DC=local", 
      new Attribute("objectClass", "top", "group"), 
      new Attribute("name","TestGroup2"), 
      new Attribute("sAMAccountName","TestGroup2"), 
      new Attribute("objectCategory","CN=Group,CN=Schema,CN=Configuration,DC=domain,DC=local") 
      ) 

請注意,我已經刪除了幾個屬性,包括sAMAccountType,這是由AD拒絕。我也刪除了一些冗餘的。我相信我擁有的是滿足我需求的最小屬性集。

連接代碼未更改。