Bash 스크립트에서 다양한 디렉터리 서버에 대해 허용 가능한 LDAP 기본 DN 기본값을 검색하려고 합니다.

Bash 스크립트에서 다양한 디렉터리 서버에 대해 허용 가능한 LDAP 기본 DN 기본값을 검색하려고 합니다.

기본적으로 특정 호스트 이름을 가리킬 때 기본 DN에 허용되는 기본값을 결정하는 스크립트를 작성하고 있습니다. 나는 그것을 ldapsearch출력 주위에 감싼다.

  • 루트 DSE를 직접 보고 끌어서 Active Directory를 수행할 수 있습니다.defaultNamingContext
  • objectClass의 DSE 필터링 아래에서 직접 단일 수준 검색을 시작하고 첫 번째 검색만 수행하여 Domino를 수행할 수 있습니다 dominoOrganization. 이는 기본값이므로 정확하지 않은 경우 변경할 수 있습니다.
  • 루트 DSE를 직접 보고 첫 번째 값을 추출하여 OpenLDAP를 수행할 수 있습니다.namingContexts

하지만 만일을 대비해 eDirectory도 지원하고 싶습니다. 문제는 그것을 볼 수 있는 eDirectory가 설치되어 있지 않고, 무료 소프트웨어가 아니기 때문에 어떻게 설정되어 있는지 확인하기 위해 테스트 버전을 설치할 수 없다는 것입니다.

Novell의 웹사이트를 보면 실제로 defaultNamingContextAD와 동일한 작업을 수행하지 않는 것처럼 보이며 확실히 dominoOrganization objectClass를 수행하지 않는 것 같습니다. eDirectory에서 본 대부분의 예제 DN은 o=OrganizationNameDomino에도 존재하는 것처럼 사용되는 것처럼 보이지만 o=OrganizationName,C=US국가 약어가 기본 DN에 있을 수 있거나 있을 수 없는 경우에도 마찬가지입니다. one_level 이상의 작업을 수행합니다.

더 나쁜 것은 디렉토리 서버가 분할되어 있거나(일부 AD 구성에서와 같이) Domino와 같이 중요한 LDAP 정보를 찾을 수 있는 위치를 반영하지 않는 많은 기본 조직이 내장되어 있는 경우입니다. 예를 들어, O=RSA Data Security\, Inc.,C=US지금 보고 있는 Domino LDAP 인스턴스에는 조직이 있습니다.

루트 DSE에서 검색을 시작하면 특정 개체 클래스를 필터링할 수 있습니까? 나는 이것이 비용이 많이 드는 검색이라는 것을 알고 있습니다(특히 전체 범위를 얻어야 하는 경우 sub). 그러나 이것은 가끔 발생하는 일입니다.

간단히 말해서:eDirectory에서 기업 조직의 기반은 어떤 식별 속성을 갖고 있습니까? 검색 기준을 루트 DSE로 설정한 경우 어떻게 찾나요?

나는 eDirectory 서버에서 이 스크립트를 실행해야 하는 기회를 만날 때까지 코드가 작동하는지 확인할 수 없기 때문에 예제를 선호합니다(우리는 교육 수준이 높기 때문에 확실히 가능합니다).

답변1

namingContext대부분의 디렉터리에 있는 루트 DSE 개체에 대해 매우 일반적인 것 같습니다. 따라서 합리적인 기본값은 일반적으로 첫 번째 항목을 선택하는 것입니다(DSA가 AD와 같이 첫 번째 항목을 기본값으로 특별히 설정하지 않는 한). 동일한 비 AD DSA에 여러 파티션/DIT가 있는 독특한 구성이 있는 경우 동일한 관리자는 첫 번째 경우 적절한 기본 DN이 무엇인지 충분히 알 수 있습니다.namingContext 아니요그 아래에서 사용자/그룹을 찾아야 합니다.

기본 DN 기본 자동 감지를 실행하는 방법에 대한 의사 코드다양한 DSA의 경우:

  # Active Directory Test
  # rootDSE lists acceptable default base DN for us
If "1.2.840.113556.1.4.800" in rootDSE["supportedCapabilities"]:
    defaultBase = rootDSE["defaultNamingContext"]

  # IBM Domino LDAP Test
  # Take the dn of the first dominoOrganization Object we find
If "IBM Lotus Software" == rootDSE["vendorname"]
    ldapsearch -LLL "objectClass=dominoOrganization" dn | head -1

  # eDirectory Test
  # Take the first Partition Object we find
If "Novell Inc." == rootDSE["vendorName"]
    ldapsearch -LLL "objectClass=Partition" dn | head -1

  # OpenLDAP Tests
  # This is the same as the default action so not technically required but it shows 
  # how you identify OpenLDAP DSA's. It's possible to nest some additional checks/searches
  # here for the various types of top level containers (For example to prefer domain 
  # container-style entries to org-style, etc).
If "OpenLDAProotDSE" in rootDSE["objectClass"]
    ldapsearch -LLL -b '' -s base namingContext | head -1

  # Apache DS Tests
  # Same as above, not technically required but it shows how you identify Apache DS
If "Apache Software Foundation" in rootDSE["vendorName"]
    ldapsearch -LLL -b '' -s base namingContext | head -1

  # Default to taking the first namingContext attribute if present but no tests works
If $(ldapsearch -LLL -b '' -s base namingContexts | head -1 | cut -d: -f2 | wc -c ) > 1
   ldapsearch -LLL -b '' -s base namingContext | head -1

  # I'm out of ideas on how to find a base DN so ultimately default to something explicit

return "(null)"

OpenLDAP DSA에서 올바른 기본 DN 결정:

[root@policyServer ~]# ldapsearch -x -LLL -H ldap://localhost -b '' -s base + | egrep "^namingContexts:" | head -1 | cut -d: -f2
 dc=trunkator,dc=com
[root@policyServer ~]#

참고로 동일한 DSA의 전체 루트 DSE는 다음과 같습니다.(완전한 설명을 위해 여러 DIT를 나열했습니다):

[root@policyServer ~]# ldapsearch -x -LLL -H ldap://localhost -b '' -s base +
dn:
structuralObjectClass: OpenLDAProotDSE
configContext: cn=config
monitorContext: cn=Monitor
namingContexts: dc=trunkator,dc=com
namingContexts: dc=localhost
supportedControl: 2.16.840.1.113730.3.4.18
supportedControl: 2.16.840.1.113730.3.4.2
supportedControl: 1.3.6.1.4.1.4203.1.10.1
supportedControl: 1.2.840.113556.1.4.319
supportedControl: 1.2.826.0.1.3344810.2.3
supportedControl: 1.3.6.1.1.13.2
supportedControl: 1.3.6.1.1.13.1
supportedControl: 1.3.6.1.1.12
supportedExtension: 1.3.6.1.4.1.1466.20037
supportedExtension: 1.3.6.1.4.1.4203.1.11.1
supportedExtension: 1.3.6.1.4.1.4203.1.11.3
supportedExtension: 1.3.6.1.1.8
supportedFeatures: 1.3.6.1.1.14
supportedFeatures: 1.3.6.1.4.1.4203.1.5.1
supportedFeatures: 1.3.6.1.4.1.4203.1.5.2
supportedFeatures: 1.3.6.1.4.1.4203.1.5.3
supportedFeatures: 1.3.6.1.4.1.4203.1.5.4
supportedFeatures: 1.3.6.1.4.1.4203.1.5.5
supportedLDAPVersion: 3
supportedSASLMechanisms: GSSAPI
entryDN:
subschemaSubentry: cn=Subschema

관련 정보