LDAP データ交換形式 (LDIF) は、LDAP サービス プロバイダーを使用するディレクトリ サーバー間でディレクトリ データをインポートおよびエクスポートする方法を定義するインターネット エンジニアリング タスク フォース (IETF) 標準です。 Windows 2000 および Windows Server 2003 には、LDIF ファイルを使用して Active Directory Domain Services にディレクトリ オブジェクトをインポートするために使用できるコマンド ライン ユーティリティ LDIFDE が含まれています。 LDIFDE を使用すると、スキーマ管理者が簡単に読み取ることができる LDIF ファイルとして Active Directory Domain Services 内のディレクトリ オブジェクトを検索および一覧表示するために、フィルターを特定の文字列に設定できます。
Unicode ファイルをインポートするときに、ファイルの先頭に Unicode 識別子が含まれている場合、LDIFDE はファイルを Unicode としてインポートします。 ファイルの先頭に Unicode 識別子が含まれていないときにファイルを Unicode としてインポートする場合は、-u スイッチを使用して Unicode として強制的にインポートできます。
ファイルをエクスポートするための既定のモードは ANSI です。 Unicode エントリがある場合は、Base 64 形式に変換されます。 ファイルを Unicode 形式でエクスポートするには、-u スイッチを使用します。
追加される属性間に依存関係がある場合は、LDIF ファイルでスキーマの変更を適用する必要があります。 たとえば、前方リンク属性は、対応するバック リンク属性の前に追加する必要があります。 また、LDIF スクリプトで前に追加した属性またはクラスに依存するクラスを追加する前に、スキーマ キャッシュを更新する必要があります。 詳細については、次のコード例を参照してください。
バイナリ値の場合は、値を base64 としてエンコードする必要があることに注意してください。 Base64 エンコードは、IETF RFC 2045 セクション 6.8 で定義されています。
LDIF ファイルの形式の詳細については、「LDAP データ交換形式 (LDIF) - 技術仕様 (RFC 2849) 」を参照してください。
NTDS 固有の LDIF 変更タイプ
ldifde -k を呼び出すのではなく、ntdsSchema* changetype を使用することをお勧めします。 ldifde の -k オプションは、より大きな LDAP エラーのセットを無視します。 無視されるエラーの完全な一覧は次のとおりです。
- オブジェクトは既にグループのメンバーです。
- インポートするオブジェクトに他の属性がない場合、オブジェクト クラス違反 (指定したオブジェクト クラスが存在しないことを意味します)。
- オブジェクトは既に存在します (LDAP_ALREADY_EXISTS)
- 制約違反 (LDAP_CONSTRAINT_VIOLATION)
- 属性または値は既に存在します (LDAP_ATTRIBUTE_OR_VALUE_EXISTS)
- そのようなオブジェクトはありません (LDAP_NO_SUCH_OBJECT)
次の変更タイプは、スキーマのアップグレード操作専用に設計されています。
Changetype | 形容 |
---|---|
ntdsSchemaAdd を する |
ntdsSchemaAdd は、LDIF ファイルに を追加 に対応します。 唯一の違いは、ntdsSchemaAdd 、オブジェクトが既にスキーマに存在する場合、ldifde が 追加操作をスキップ。 (LDAP_ALREADY_EXISTS は無視されます。 |
ntdsSchemaModify を する |
ntdsSchemaModify 、LDIF ファイル内の 変更に対応します。 唯一の違いは、ntdsSchemaModify 、オブジェクトがスキーマで見つからない場合、ldifde が 変更 操作をスキップするということです。 (LDAP_NO_SUCH_OBJECT は無視されます。 |
ntdsSchemaDelete を する |
ntdsSchemaDelete は、LDIF ファイル内 削除 に対応します。 唯一の違いは、ntdsSchemaDelete 、オブジェクトがスキーマに見つからない場合、ldifde によって 削除 操作がスキップされるということです。 (LDAP_NO_SUCH_OBJECT は無視されます。 |
ntdsSchemaModRdn を する |
ntdsSchemaModRdn は、LDIF ファイル modrdn に対応します。 唯一の違いは、ntdsSchemaModRdn 、オブジェクトがスキーマで見つからない場合、ldifde によって相対識別名の変更操作がスキップされるということです。 (LDAP_NO_SUCH_OBJECT は無視されます。 |
例
次のコード例は次のとおりです。
Myschemaext.ldf は、新しい属性とクラスを含む LDIF スクリプトです。 このファイルは、Lgetattcls.vbs から生成されたファイルの変更されたバージョンであることに注意してください。 また、バック リンク (My-Test-Attribute-DN-BL) は前方リンク (my-Test-Attribute-DN-FL) に依存しているため、My-Test-Attribute-DN-FL 属性は My-Test-Attribute-DN-BL より前に移動されていることにも注意してください。 さらに、schemaUpdateNow 操作属性は、スクリプトに 2 つのクラスを追加するために依存属性とクラスを使用できるように、スキーマ キャッシュの更新をトリガーするために 2 つの場所に設定されます。
手記
linkID: ステートメント内の ID のソースについては、「リンク ID の取得」を参照してください。
Lgetattcls.vbs は、Myschemaext.ldf の開始点として使用される LDIF スクリプトを生成する VBScript ファイルです。 現在のスキーマ パスは CN=Schema,CN=Configuration,DC=myorg,DC=com に置き換えられます。 DC=myorg,DC=com を置き換えて、LDIF スクリプトで公開する識別名 (DN) を反映することで、LSETATTCLS が確実に行われるようにすることができます。VBS は、LDIF スクリプトの適用時に正しい DN が置き換えられるように、sFromDN の変更を反映します。 また、スクリプトではプレフィックスを使用して、定義する必要があるクラスと属性を検索し、すべてのクラスと属性にプレフィックスを使用する必要があることにも注意してください。 詳細については、「名前付け属性とクラスの」を参照してください。 さらに、スクリプトは、属性Schema に必要な属性のみを出力し、classSchema オブジェクトを LDIF ファイルに出力します。
Lsetattcls.vbs は、Myschemaext.ldf スクリプトを使用してスクリプトに新しい属性とクラスを追加する VBScript ファイルです。 スクリプトを実行する前に、スキーマ マスターが書き込み可能であることを確認します。
MYSCHEMAEXT。LDF
dn: CN=My-Test-Attribute-CaseExactString,CN=Schema,CN=Configuration,DC=myorg,DC=com
changetype: add
adminDisplayName: My-Test-Attribute-CaseExactString
attributeID: 1.2.840.113556.1.4.7000.159.24.10.65
attributeSyntax: 2.5.5.3
cn: My-Test-Attribute-CaseExactString
description: Test attribute of syntax CaseExactString used to show how to add a CaseExactString attribute.
isMemberOfPartialAttributeSet: FALSE
isSingleValued: TRUE
lDAPDisplayName: myTestAttributeCaseExactString
distinguishedName: CN=My-Test-Attribute-CaseExactString,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectCategory: CN=Attribute-Schema,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectClass: attributeSchema
oMSyntax: 27
name: My-Test-Attribute-CaseExactString
schemaIDGUID:: 6ASznA3W0hGBpwDAT7mMGg==
searchFlags: 0
dn: CN=My-Test-Attribute-DN-FL,CN=Schema,CN=Configuration,DC=myorg,DC=com
changetype: add
adminDisplayName: My-Test-Attribute-DN-FL
attributeID: 1.2.840.113556.1.4.7000.159.24.10.614
attributeSyntax: 2.5.5.1
cn: My-Test-Attribute-DN-FL
description: Test forward link attribute of syntax DN used to show how to add a forward link attribute. Back link is My-Test-Attribute-DN-BL.
isMemberOfPartialAttributeSet: FALSE
isSingleValued: TRUE
lDAPDisplayName: myTestAttributeDNFL
linkID: 1.2.840.113556.1.2.50
distinguishedName: CN=My-Test-Attribute-DN-FL,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectCategory: CN=Attribute-Schema,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectClass: attributeSchema
oMObjectClass:: KwwCh3McAIVK
oMSyntax: 127
rangeLower: 0
rangeUpper: 257
name: My-Test-Attribute-DN-FL
schemaIDGUID:: YGLudffa0hGLEwDAT7mMGg==
searchFlags: 0
dn: CN=My-Test-Attribute-DN-BL,CN=Schema,CN=Configuration,DC=myorg,DC=com
changetype: add
adminDisplayName: My-Test-Attribute-DN-BL
attributeID: 1.2.840.113556.1.4.7000.159.24.10.615
attributeSyntax: 2.5.5.1
cn: My-Test-Attribute-DN-BL
description: Test back link attribute of syntax DN used to show how to add a back link attribute. Forward link is My-Test-Attribute-DN-FL.
isMemberOfPartialAttributeSet: FALSE
isSingleValued: TRUE
lDAPDisplayName: myTestAttributeDNBL
linkID: 1.2.840.113556.6.1234
distinguishedName: CN=My-Test-Attribute-DN-BL,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectCategory: CN=Attribute-Schema,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectClass: attributeSchema
oMObjectClass:: KwwCh3McAIVK
oMSyntax: 127
rangeLower: 0
rangeUpper: 257
name: My-Test-Attribute-DN-BL
schemaIDGUID:: jFfbhffa0hGLEwDAT7mMGg==
searchFlags: 0
dn: CN=My-Test-Attribute-DN-Regular,CN=Schema,CN=Configuration,DC=myorg,DC=com
changetype: add
adminDisplayName: My-Test-Attribute-DN-Regular
attributeID: 1.2.840.113556.1.4.7000.159.24.10.613
attributeSyntax: 2.5.5.12
cn: My-Test-Attribute-DN-Regular
description: Test attribute of syntax DN used to show how to add a DN attribute.
isMemberOfPartialAttributeSet: FALSE
isSingleValued: TRUE
lDAPDisplayName: myTestAttributeDNRegular
distinguishedName: CN=My-Test-Attribute-DN-Regular,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectCategory: CN=Attribute-Schema,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectClass: attributeSchema
oMObjectClass:: KwwCh3McAIVK
oMSyntax: 64
rangeLower: 0
rangeUpper: 257
name: My-Test-Attribute-DN-Regular
schemaIDGUID:: 5QSznA3W0hGBpwDAT7mMGg==
searchFlags: 0
dn: CN=My-Test-Attribute-DNString,CN=Schema,CN=Configuration,DC=myorg,DC=com
changetype: add
adminDisplayName: My-Test-Attribute-DNString
attributeID: 1.2.840.113556.1.4.7000.159.24.10.611
attributeSyntax: 2.5.5.14
cn: My-Test-Attribute-DNString
description: Test attribute of syntax DNString used to show how to add a DNString attribute.
isMemberOfPartialAttributeSet: FALSE
isSingleValued: TRUE
lDAPDisplayName: myTestAttributeDNString
distinguishedName: CN=My-Test-Attribute-DNString,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectCategory: CN=Attribute-Schema,CN=Schema,CN=Configuration,DC=myorg,DC=com
objectClass: attributeSchema
oMObjectClass:: KoZIhvcUAQEBDA==
oMSyntax: 127
rangeLower: 1
rangeUpper: 64
name: My-Test-Attribute-DNString
schemaIDGUID:: 5ASznA3W0hGBpwDAT7mMGg==
searchFlags: 0
DN:
changetype: modify
add: schemaUpdateNow
schemaUpdateNow: 1
-
dn: CN=My-Test-Auxiliary-Class1,CN=Schema,CN=Configuration,DC=Fabrikam,DC=com
changetype: add
adminDisplayName: My-Test-Auxiliary-Class1
description: Test class used to show how to add an auxiliary class.
objectCategory: CN=Class-Schema,CN=Schema,CN=Configuration,DC=Fabrikam,DC=com
objectClass: classSchema
lDAPDisplayName: myTestAuxiliaryClass1
governsID: 1.2.840.113556.1.4.7000.159.24.10.611.11
instanceType: 4
objectClassCategory: 3
schemaIDGUID:: mmsxdsXb0hGL0AAA+HW2YA==
subClassOf: Top
mayContain: my-Test-Attribute-DNString
mustContain: description
DN:
changetype: modify
add: schemaUpdateNow
schemaUpdateNow: 1
-
dn: CN=My-Test-Structural-Class1,CN=Schema,CN=Configuration,DC=Fabrikam,DC=com
changetype: add
adminDisplayName: My-Test-Structural-Class1
auxiliaryClass: myTestAuxiliaryClass1
defaultHidingValue: FALSE
defaultObjectCategory: CN=Organizational-Unit,CN=Schema,CN=Configuration,DC=Fabrikam,DC=com
defaultSecurityDescriptor: D:(A;;RPWPCRCCDCLCLOLORCWOWDSDDTDTSW;;;DA)(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)(A;;RPLCLORC;;;AU)
admindescription: Test class used to show how to add a structure class.
objectCategory: CN=Class-Schema,CN=Schema,CN=Configuration,DC=Fabrikam,DC=com
objectClass: classSchema
lDAPDisplayName: myTestStructuralClass1
governsID: 1.2.840.113556.1.4.7000.159.24.10.611.12
mayContain: myTestAttributeDNFL
mayContain: wWWHomePage
mustContain: url
instanceType: 4
objectClassCategory: 1
possSuperiors: organizationalUnit
rDNAttID: ou
schemaIDGUID:: 1HsnsL7b0hGL0AAA+HW2YA==
subClassOf: organizationalUnit
DN:
changetype: modify
add: schemaUpdateNow
schemaUpdateNow: 1
-
LGETATTCLS。VBS
On Error Resume Next
'''''''''''''''''''
' Bind to the rootDSE
'''''''''''''''''''
sPrefix = "LDAP://"
Set root= GetObject(sPrefix & "rootDSE")
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on GetObject method"
End If
'''''''''''''''''''
' Get the DN for the Schema
'''''''''''''''''''
sSchema = root.Get("schemaNamingContext")
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on Get method"
End If
'''''''''''''''''''
' Bind to the Schema container
'''''''''''''''''''
Set Schema= GetObject(sPrefix & sSchema )
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on GetObject method to bind to Schema"
End If
''''''''''''''''''''
' Read the fsmoRoleOwner attribute to see which server is the schema master.
''''''''''''''''''''
sMaster = Schema.Get("fsmoRoleOwner")
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on IADs::Get method for fsmoRoleOwner"
End If
''''''''''''''''''''
' fsmoRoleOwner attribute returns the nTDSDSA object.
' The parent is the server object.
' Bind to NTDSDSA object and get parent
''''''''''''''''''''
Set NTDS = GetObject(sPrefix & sMaster)
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on GetObject method for NTDS"
End If
sServer = NTDS.Parent
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on IADs::get_Parent method"
End If
''''''''''''''''''''
' Bind to server object and get the
' reference to the computer object.
''''''''''''''''''''
Set Server = GetObject(sServer)
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on GetObject method for " & sServer
End If
'''''''''''''''''''''
' Display the DN for the computer object.
'''''''''''''''''''''
sComputerDNSName = Server.Get("DNSHostName")
strText = "Schema Master has the following DNS Name: "& sComputerDNSName
WScript.echo strText
sFile = "myschemaext1.ldf"
sFromDN = sSchema
sToDN = "CN=Schema,CN=Configuration,DC=myorg,DC=com"
sAttrPrefix = "My-Test"
sFilter = "(&((cn=" & sAttrPrefix & "*)(|(objectCategory=classSchema)_
(objectCategory=attributeSchema))))"
sRetAttr = "dn,adminDescription,adminDisplayName,governsID,cn,mayContain,_
mustContain,systemMayContain,systemMustContain,lDAPDisplayName,_
objectClassCategory,distinguishedName,objectCategory,objectClass,_
possSuperiors,systemPossSuperiors,subClassOf,defaultObjectCategory,_
name,schemaIDGUID,auxiliaryClass,auxiliaryClass,systemAuxiliaryClass,_
description,defaultHidingValue,rDNAttId,defaultSecurityDescriptor,_
attributeID,attributeSecurityGUID,attributeSyntax,_
isMemberOfPartialAttributeSet,isSingleValued,mAPIID,oMSyntax,rangeLower,_
rangeUpper,searchFlags,oMObjectClass,linkID"
' Add flag rootDN.
sCommand = "ldifde -d " & sSchema
sCommand = sCommand & " -c " & sFromDN & " " & sToDN
' Add flag schema master.
sCommand = sCommand & " -s " & sComputerDNSName
' Add flag filename.
sCommand = sCommand & " -f " & sFile
' Add flag filter to search for attributes.
sCommand = sCommand & " -r " & sFilter
' Add flag for attributes to return.
sCommand = sCommand & " -l " & sRetAttr
WScript.echo sCommand
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run (sCommand)
''''''''''''''''''''
' Display subroutines
''''''''''''''''''''
Sub BailOnFailure(ErrNum, ErrText) strText = "Error 0x"_
& Hex(ErrNum) & " " & ErrText
MsgBox strText, vbInformation, "ADSI Error"
WScript.Quit
End Sub
LSETATTCLS。VBS
On Error Resume Next
'''''''''''''''''''
' Bind to the rootDSE
'''''''''''''''''''
sPrefix = "LDAP://"
Set root= GetObject(sPrefix & "rootDSE")
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on GetObject method"
End If
'''''''''''''''''''
' Get the DN for the Schema
'''''''''''''''''''
sSchema = root.Get("schemaNamingContext")
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on Get method"
End If
'''''''''''''''''''
' Bind to the Schema container
'''''''''''''''''''
Set Schema= GetObject(sPrefix & sSchema )
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on GetObject method to bind to Schema"
End If
''''''''''''''''''''''''''''''''''''''
' Read the fsmoRoleOwner attribute to see which server is the schema master.
''''''''''''''''''''''''''''''''''''''
sMaster = Schema.Get("fsmoRoleOwner")
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on IADs::Get method for fsmoRoleOwner"
End If
'''''''''''''''''''''''''''
' fsmoRoleOwner attribute returns the nTDSDSA object.
' The parent is the server object.
' Bind to NTDSDSA object and get parent
'''''''''''''''''''''''''''
Set NTDS = GetObject(sPrefix & sMaster)
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on GetObject method for NTDS"
End If
sServer = NTDS.Parent
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on IADs::get_Parent method"
End If
''''''''''''''''''''''''
' Bind to server object
' and get the reference to the computer object.
''''''''''''''''''''''''
Set Server = GetObject(sServer)
If (Err.Number <> 0) Then
BailOnFailure Err.Number, "on GetObject method for " & sServer
End If
sComputer = Server.Get("serverReference")
'''''''''''''''''''''
' Display the DN for the computer object.
'''''''''''''''''''''
sComputerDNSName = Server.Get("DNSHostName")
' strText = "Schema Master has the following DN: "& sComputer
strText = "Schema Master has the following DNS Name: "& sComputerDNSName
WScript.echo strText
sFile = "myschemaext.ldf"
sFromDN = "CN=Schema,CN=Configuration,DC=myorg,DC=com"
sToDN = sSchema
' Add flag replace fromDN with ToDN.
sCommand = "ldifde -i -k -c " & sFromDN & " " & sToDN
' Add flag schema master.
sCommand = sCommand & " -s " & sComputerDNSName
'Add flag filename.
sCommand = sCommand & " -f " & sFile
' Add flag filter to search for my attributes.
WScript.echo sCommand
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run (sCommand)
''''''''''''''''''''
' Display subroutines
''''''''''''''''''''
Sub BailOnFailure(ErrNum, ErrText) strText = "Error 0x" & Hex(ErrNum) & " " & ErrText
MsgBox strText, vbInformation, "ADSI Error"
WScript.Quit
End Sub