Le Microsoft Visual Basic Script (de VBScript) fourni dans cet article rechercheront un objet par son nom dans l'annuaire et tentera d'effacer le sidHistory pour l'objet. Il a des paramètres facultatifs pour objectClass et objectcategory destiné dans la recherche à s'aider.
Déplacement d'un domaine, un nouvel identificateur de sécurité (SID) de devoir quand être généré du compte d'utilisateur et devoir être stocké dans la propriété
Object-SID d'un objet utilisateur à autre. Avant que la valeur nouvelle soit écrite dans la propriété, la valeur précédente est copiée dans une autre propriété d'un objet User,
SID-History (sidHistory). Cette propriété peut contenir plusieurs valeurs. Chaque heure lequel un objet User déplace qu'un nouvel identificateur de sécurité est généré et est stocké dans la propriété
Object-SID et une autre valeur vers un autre domaine est ajoutée à la liste de SID ancien dans
SID-History. Désactiver le
sidHistory peut être parfois nécessaire.
Le code suivant VBScript supprimera l'attribut
sidHistory de l'objet d'annuaire spécifié dans les arguments de ligne de commande.
- Ouvrez Bloc-notes Microsoft.
- Copiez le code suivant et le collez dans votre document Bloc-notes.
Const ADS_PROPERTY_DELETE = 4
Dim strFilter 'As String
Dim oConnection 'As ADODB.Connection
Dim oRecordSet 'As ADODB.RecordSet
Dim strQuery 'As String
Dim strDomainNC 'As String
Dim oRootDSE 'As IADs
Dim vArray 'As Variant()
Dim vSid 'As Variant
Dim oDirObject 'As Variant
' Parse the command line and set the query filter
ParseCommandLine()
' Find the domain naming context
set oRootDSE = GetObject("LDAP://RootDSE")
strDomainNC = oRootDSE.Get("defaultNamingContext")
set oRootDSE = Nothing
' Setup the ADO connection
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
strQuery = "<LDAP://" & strDomainNC & ">;" & strFilter & ";distinguishedName,objectClass,name,sidHistory;subtree"
'Execute the query
set oRecordSet = oConnection.Execute(strQuery)
if oRecordSet.Eof then
WScript.Echo "No objects were found"
WScript.Quit(0)
Else
Dim vClasses 'As Variant
Dim strClass 'As String
WScript.Echo "The following objects were found:"
'On Error Resume Next
' Iterate through the objects that match the filter
While Not oRecordset.Eof
vClasses = oRecordset.Fields("objectClass").Value
strClass = vClasses(UBound(vClasses))
WScript.Echo "Name: " & oRecordset.Fields("name").Value & " Class: " & strClass & " DN: " & oRecordset.Fields("distinguishedName").Value
If IsNull(oRecordSet.Fields("sIDHistory").Value ) Then
WScript.Echo "This object does not have a sidHistory"
Else
set oDirObject = GetObject("LDAP://" & oRecordset.Fields("distinguishedName").Value)
vArray = oDirObject.GetEx("sIDHistory")
For Each vSid in vArray
oDirObject.PutEx ADS_PROPERTY_DELETE, "sIDHistory", array(vSid)
oDirObject.SetInfo
Next
WScript.Echo "The sidHistory has been cleared for this object!"
End if
oRecordset.MoveNext
Wend
End if
'Clean up
Set oRecordset = Nothing
Set oConnection = Nothing
'=========================================================================================================================
' The ParseCommandLine subroutine will build the query filter base on the arguments passed to the script. The bNameFlag
' is used so that the name given can have spaces in it.
'=========================================================================================================================
Sub ParseCommandLine()
Dim vArgs, Value, Equals, I
Dim bNameFlag 'As Boolean
Dim strName 'As String
Dim strObjectCategory 'As String
Dim strObjectClass 'As String
Set vArgs = WScript.Arguments
if VArgs.Count < 1 Then
DisplayUsage()
End if
bNameFlag = False
For I = 0 to vArgs.Count - 1
If Left( vArgs(I) , 1 ) = "/" Or Left( vArgs(I) , 1 ) = "-" Then
Value = ""
Equals = InStr( vArgs(I) , "=" )
If Equals = 0 Then Equals = InStr( vArgs(I) , ":" )
If Equals > 0 Then Value = Mid( vArgs(I) , Equals + 1 )
Select Case LCase( Mid( vArgs(I) , 2 , 1) )
Case "n" strName = Value
bNameFlag = True 'This will allow us to catch spaces
Case "o" strObjectCategory = Value
bNameFlag = False
Case "c" strObjectClass = Value
bNameFlag = False
Case Else DisplayUsage
End Select
Else 'no dash or slash; Check if we are giving a name
if bNameFlag Then
strName = strName & " " & vArgs(I)
else
DisplayUsage
end if
End if
Next
'Should be okay to build filter
If strName = "" Then
WScript.Echo "A name parameter must be given"
WScript.Quit(1)
Else
strFilter = "(&(name=" & strName & ")"
If Len(strObjectCategory) > 0 Then
strFilter = strFilter & "(objectCategory=" & strObjectCategory & ")"
End if
If Len(strObjectClass) > 0 Then
strFilter = strFilter & "(objectClass=" & strObjectClass & ")"
End if
strFilter = strFilter & ")" 'Close filter
End if
End Sub
'=========================================================================================================================
' The DisplayUsage subroutine will display how to use this script, the objectCategory and objectClass arguments are optional.
'=========================================================================================================================
Sub DisplayUsage()
WScript.Echo "Usage csript.exe " & WScript.ScriptName & vbLF & _
"-n=<name of the object you are looking for>" & vbLF & _
"[-o=<objectCategory of the object you are looking for>]" & vbLF & _
"[-c=<objectClass of the object you are looking for>]" & vbLF & vbLF & _
"Examples : " & vbLF & _
WScript.ScriptName & " -n=My Contact" & vbLF & _
WScript.ScriptName & " -n=Computer1 -o=computer" & vbLF & _
WScript.ScriptName & " -n=James Smith -o=Person -c=user"
WScript.Quit(0)
End Sub
- Enregistrez le document comme C:\ClearSidHistory.vbs
-
Exécutez le code Il y a utilisation pour ClearSidHistory.vbs comme suit :
cscript.exe -n ClearSidHistory.vbs = <name> [ - o = <objectCategory> ] [ - C = <objectClass> ]
-n = <name of the object you are looking for>
-o = <objectCategory of the object you are looking for>
-c = <objectClass of the object you are looking for>
Exemples :
Cscript.exe -n ClearSidHistory.vbs = mon contact
Cscript.exe -n ClearSidHistory.vbs = -o Ordinateur1 = ordinateur
cscript.exe -n ClearSidHistory.vbs = -o James Smith = -c Person = utilisateur
Numéro d'article: 295758 - Dernière mise à jour: mardi 30 août 2005 - Version: 3.2
Les informations contenues dans cet article s'appliquent au(x) produit(s) suivant(s):
- Microsoft Windows 2000 Server
- Microsoft Active Directory Service Interfaces 2.5
| kbhowto kb32bitonly kbprb KB295758 KbMtfr kbmt |
Traduction automatiqueTRADUCTION AUTOMATIQUE : Cet article technique a été traduit par un système automatique, c'est-à-dire sans aucune intervention humaine. Microsoft propose ce type d?articles en complément de ceux traduits par des traducteurs professionnels. Ces articles sont destinés principalement aux utilisateurs ne comprenant pas l'anglais en leur proposant, en complément, une version française de l?information technique fournie dans la version américaine et originale de l?article.
Pour plus de détails, veuillez consulter la page http://support.microsoft.com/gp/mtdetails.
Attention : Il est possible que certaines parties de l?article ne soient pas traduites par le système automatique et qu?elles soient restées rédigées en anglais. Microsoft ne garantit pas la qualité linguistique des traductions et ne peut être tenu responsable d?aucun problème, direct ou indirect, dû à une quelconque erreur de traduction du contenu ou de son utilisation par les utilisateurs.
La version anglaise de cet article est la suivante:
295758
(http://support.microsoft.com/kb/295758/en-us/
)
L'INFORMATION CONTENUE DANS CE DOCUMENT EST FOURNIE PAR MICROSOFT SANS GARANTIE D'AUCUNE SORTE, EXPLICITE OU IMPLICITE. L'UTILISATEUR ASSUME LE RISQUE DE L'UTILISATION DU CONTENU DE CE DOCUMENT. CE DOCUMENT NE PEUT ETRE REVENDU OU CEDE EN ECHANGE D'UN QUELCONQUE PROFIT.