我正在尝试从 MS AD 检索一些信息:特定分支机构的成员、部门名称、职位等。
\n\n我使用了很多示例,包括Apache Directory LDAP API和UnboundID,但我无法与 AD 连接。
\n\nRDN:
\n\nC:\\Users\\Aleksey> whoami /fqdn\n       CN=my common name here,\n       OU=my organization unit here,\n       OU=organization unit 2 here,\n       OU=organization unit 1 here,\n       OU=main organization unit here,\n       DC=.my domain here,\n       DC=domain 2 here,\n       DC=main domain here\n为了进行搜索,我使用以下过滤器:
\n\npublic class LdapRetriever {\n    public static void main (String[] args) {\n        Hashtable env = new Hashtable();\n\n        env.put(Context.INITIAL_CONTEXT_FACTORY, \n            "com.sun.jndi.ldap.LdapCtxFactory");\n        env.put(Context.PROVIDER_URL, "ldap://" + \n            "ip of domain controller here" + ":389");\n        env.put(Context.SECURITY_AUTHENTICATION, "simple");\n        // Also I try to use the following SECURITY_PRINCIPAL: \n        // my login only, my domain\\ my login\n        env.put(Context.SECURITY_PRINCIPAL, "my login here" + "@" + \n            "my domain here.domain 2 here.main domain here");\n        env.put(Context.SECURITY_CREDENTIALS, "my password here");\n\n        try {           \n            DirContext ctx = new InitialLdapContext(env,null);\n            String returnedAtts[]={"sn","title","department","givenName"};\n\n            SearchControls searchCtls = new SearchControls();  \n            searchCtls.setReturningAttributes(returnedAtts);  \n            searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);\n\n            String searchFilter = "(&(objectClass=user)(cn=*))";\n            String searchBase = \n                "DC=my domain here,DC=domain 2 here,DC=main domain here";\n\n            NamingEnumeration answer = ctx.search(searchBase, \n                searchFilter, searchCtls);\n            ...\n当我使用来自的数据创建目录上下文时env出现异常:
Exception in thread "main" javax.naming.AuthenticationException: \n[LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment:\nAcceptSecurityContext error, data 531, vece\n如果未指定密码,则会出现以下异常:
\n\nProblem searching directory: \njavax.naming.NamingException:[LDAP:error code 1 - 00000000: \nLdapErr: DSID-0C090627, comment: \nIn order to perform this operation a successful bind must be completed \non the connection., data 0, vece]; remaining name \n\'DC=my domain here,DC=domain 2 here,DC=main domain here\'\n我已经确认我的帐户没有被锁定。
\n\n根据常见 Active Directory LDAP 绑定错误列表:
\n\n\n\n\nRun Code Online (Sandbox Code Playgroud)\n525\xe2\x80\x8b user not found \xe2\x80\x8b\n52e\xe2\x80\x8b invalid credentials \xe2\x80\x8b\n530\xe2\x80\x8b not permitted to logon at this time\xe2\x80\x8b\n531\xe2\x80\x8b not permitted to logon at this workstation\xe2\x80\x8b\n532\xe2\x80\x8b password expired \xe2\x80\x8b\n533\xe2\x80\x8b account disabled \xe2\x80\x8b\n701\xe2\x80\x8b account expired \xe2\x80\x8b\n773\xe2\x80\x8b user must reset password \xe2\x80\x8b\n775\xe2\x80\x8b user account locked\n
就我而言,这意味着:“不允许在此工作站\xe2\x80\x8b 上登录”,但使用相同的凭据我可以登录到该域。
\n\n可能是什么原因?
\n错误代码 531 很可能与 AD 的配置有关。在某些情况下,用户只能从一台工作站(例如您的工作电脑)登录。 
这是在用户的
userWorkstations字段中配置的。
当您无法使用 RDP 登录 AD 时,您需要 AD 管理员检查您的帐户中是否有此字段,以及 AD 服务器是否包含在您的用户工作站中,或者该字段已完全删除。
| 归档时间: | 
 | 
| 查看次数: | 5519 次 | 
| 最近记录: |