none
update user distinguishedName attribute

    Question


  • I use java program ldap to accept active directory
    i have two question,please help me, thanks

    i want update user informatoin, if i don't update user name or cn attribute, it can run sucess.  but when i want update name or cn attribute it error.  the error is:

    javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 00002016: Sv
    cErr: DSID-031A0FC0, problem 5003 (WILL_NOT_PERFORM), data 0

    how can i update name and cn attribute in user


    the second question is:
    i want move user from an group to another group, forexample:
    i want update user dn: CN=test1,OU=AD111,OU=中望,OU=外来服务人员,O=gdepb,DC=gdepb,DC=gov,DC=cn
    to another group with dn update to dn:CN=test1,OU=AD222,OU=中望,OU=外来服务人员,O=gdepb,DC=gdepb,DC=gov,DC=cn

    how i can move user from AD111 to AD222

        //update user
        public static void updateUserInAd(AdUserModel adModel) throws Exception {
            DirContext ctx = null;
            try {
                ctx = AdDaoUtil.getDirContext();

                String searchBase = AdConst.BasePath;
                String returnedAtts[] = {
                        "sAMAccountName", "telexNumber","cn"}; //定制返回属性
      
                String searchFilter = "(objectGUID=" + adModel.getObjectGUID() + ")";
                SearchControls searchCtls = new SearchControls();
                searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
                searchCtls.setReturningAttributes(returnedAtts);

                NamingEnumeration objs = ctx.search(searchBase, searchFilter, searchCtls);

                Map modifyMap = new HashMap();
                if (StringUtils.isNotBlank(adModel.getSAMAccountName())) {
                    modifyMap.put(returnedAtts[0], adModel.getSAMAccountName());
                }
                if (StringUtils.isNotBlank(adModel.getTelexNumber())) {
                    modifyMap.put(returnedAtts[1], adModel.getName());
                }
    //if i donot update blow attribute is can run right,   how can i update this attribute ???????????????????
                if (StringUtils.isNotBlank(adModel.getTelexNumber())) {
                    modifyMap.put(returnedAtts[2], adModel.getTelephoneNumber());
                }
                if (objs.hasMoreElements()) {
                    SearchResult sr = (SearchResult) objs.next();
                    ModificationItem[] mods = new ModificationItem[modifyMap.size()];

                    Set attrSet = modifyMap.keySet();
                    int i = 0;
                    for (Iterator iterator = attrSet.iterator(); iterator.hasNext();) {
                        String attr = (String) iterator.next();
                        String value = (String) modifyMap.get(attr);

                        mods[i] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(attr, value));
                        i++;
                    }
                    ctx.modifyAttributes(sr.getNameInNamespace(), mods);
                }

    error infomation:
    javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 00002016: Sv
    cErr: DSID-031A0FC0, problem 5003 (WILL_NOT_PERFORM), data 0
    remaining name 'CN=好的,OU=AD测试,OU=中望,OU=外来服务人员,O=gdepb,DC=gdepb,DC=gov,DC=cn'
            at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3058)
            at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2931)
            at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2737)
            at com.sun.jndi.ldap.LdapCtx.c_modifyAttributes(LdapCtx.java:1437)
            at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_modifyAttributes(Compo
    nentDirContext.java:255)
            at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(
    PartialCompositeDirContext.java:172)
            at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.modifyAttributes(
    PartialCompositeDirContext.java:161)
            at javax.naming.directory.InitialDirContext.modifyAttributes(InitialDirC%

    • Moved by Rong-Chun Zhang Tuesday, June 08, 2010 12:37 PM not a compat issue (From:Application Compatibility for Windows Development)
    Tuesday, June 08, 2010 3:56 AM