英文:
filter params for import users from AD
问题
我要导入使用这个筛选器的用户:
(&(objectClass=user)(objectCategory=PERSON))
我想添加RealName参数作为筛选器。
RealName应包含3个任意单词。
例如,RealName包含“name middle_name surname” - 可以,需要导入。
如果RealName包含“name surname”(只有两个单词) - 错误,不导入。
英文:
I'm to import users used this filter:
(&(objectClass=user)(objectCategory=PERSON))
And i want to add RealName parameter as filter.
RealName should contain 3 any words.
For example RealName contained "name middle_name surname" - it's good, need to import.
If RealName contained "name surname" (only two word) - wrong, not imported.
Can you help me with with filter?
答案1
得分: 1
LDAP 查询只能使用在 Active Directory 中存在的属性,没有名为 "RealName" 的属性。
你将不得不自己拆分输入字符串。例如,如果你得到了字符串 "Necro The Human"
,你将需要使用你正在使用的任何编程语言将其拆分为 3 个字符串。
然后,你将需要将它们插入到一个 LDAP 查询中,该查询匹配三个名称属性:givenName
、initials
和 sn
(姓氏)。
你的完成查询将看起来像这样:
(&(objectClass=user)(objectCategory=person)(givenName=Necro)(initials=The)(sn=Human))
检查一下你是使用 initials
还是 middleName
属性作为中间名。在 Active Directory Users and Computers 中,initials
属性被标记为 "Initials",所以可能是它在使用,尽管文档说它只是用于全名的缩写,或者中间名的缩写(而不是全名)。它还受到限制,只能包含 6 个字符,所以如果你存储完整的中间名,可能在使用 middleName
。
如果你公司的标准是将 displayName
设置为用户的全名,包括中间名,那么你可以直接匹配它。但我认为中间名会出现在显示名称中的情况可能相当罕见。
(&(objectClass=user)(objectCategory=person)(displayName=Necro The Human))
还有模糊名称解析,但它搜索其他属性(不仅仅是第一个/最后一个名称),而且不包括 initials
或 middleName
。我提到它只是因为它并不是很有名,你将来可能会找到一些其他用途。
英文:
LDAP queries can only use attributes that exist in Active Directory, and there is no attribute called "RealName".
You will have to split the input string yourself. So, for example, if you were given the string "Necro The Human"
, you would have to split that into 3 strings using whatever programming language you're using.
Then you will have to insert those into an LDAP query that matches the three name attributes: givenName
, initials
, and sn
(surname)
Your finished query would look something like this:
(&(objectClass=user)(objectCategory=person)(givenName=Necro)(initials=The)(sn=Human))
Check if you're using initials
or the middleName
attribute for the middle name. It's the initials
attribute that is labelled as "Initials" in Active Directory Users and Computers, so that may be what's used, even though the documentation says it's just for the initials of the full name, or middle initials (not the full middle name). It's also limited to only 6 characters, so you may be using middleName
if you're storing full middle names.
If your company has the standard of setting the displayName
to the user's full name, including middle name, then you could just match against that. But I think it would be pretty rare that the middle name would be in the display name.
(&(objectClass=user)(objectCategory=person)(displayName=Necro The Human))
There is also ambiguous name resolution, but it searches other attributes (not just the first/last name) and it does not include initials
or middleName
. I mention it only because it's not well known and you may find some other use for it one day.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论