Visual Basic ½ºÅ©¸³Æ®¸¦ »ç¿ëÇÏ¿© SidHistory ÇØÁ¦ ¹æ¹ý

±â¼ú ÀÚ·á: 295758 - ÀÌ ¹®¼­°¡ Àû¿ëµÇ´Â Á¦Ç° º¸±â.
¸ðµÎ È®´ë | ¸ðµÎ Ãà¼Ò

¿ä¾à

ÀÌ ¹®¼­¿¡¼­ Á¦°øÇÏ´Â Microsoft Visual Basic ½ºÅ©¸³Æ® (VBScript) µð·ºÅ͸®¿¡ ÀÖ´Â °³Ã¼¸¦ ÇØ´ç À̸§À¸·Î ã ¹× sidHistory ÇØ´ç °³Ã¼¿¡ ´ëÇÑ ¼±ÅÃÀ» ÇÒ °ÍÀÔ´Ï´Ù. º¸¾È ¹× °Ë»ö¿¡ µµ¿òÀÌ objectCategory ´ëÇÑ ¼±ÅÃÀû ¸Å°³ º¯¼ö°¡ ÀÖ½À´Ï´Ù.

Ãß°¡ Á¤º¸

¶§ »ç¿ëÀÚ °³Ã¼¸¦ ÇÑ µµ¸ÞÀο¡¼­ ´Ù¸¥, »õ·Î¿î º¸¾È ½Äº°ÀÚ (SID)°¡ »ç¿ëÀÚ °èÁ¤¿¡ ´ëÇØ »ý¼ºµÇ¾î ÀúÀåµÇ´Â °³Ã¼ SID ¼Ó¼ºÀ» À̵¿ÇÕ´Ï´Ù. ¼Ó¼º¿¡ »õ °ªÀ» ¾²±â Àü¿¡ »ç¿ëÀÚ °³Ã¼ÀÇ SID ±â·Ï (sidHistory) ´Ù¸¥ ¼Ó¼ºÀº ÀÌÀü °ªÀÌ º¹»çµË´Ï´Ù. ÀÌ ¼Ó¼º¿¡ ¿©·¯ °ªÀÌ Æ÷Ç﵃ ¼ö ÀÖ½À´Ï´Ù. »õ SID¸¦ ´Ù¸¥ µµ¸ÞÀÎÀ¸·Î °³Ã¼¸¦ À̵¿ÇÕ´Ï´Ù »ç¿ëÀÚ »ý¼º ¹× °³Ã¼ SID ¼Ó¼ºÀ» ´Ù¸¥ °ªÀ¸·Î ÀúÀåµÈ ¶§¸¶´Ù ÀÌÀü SID SID ±â·Ï ¿¡¼­ ¸ñ·Ï¿¡ Ãß°¡µË´Ï´Ù. °æ¿ì¿¡ µû¶ó sidHistory ¼±ÅÃÀ» ÇÊ¿äÇÒ ¼ö ÀÖ½À´Ï´Ù.

´ÙÀ½°ú °°Àº VBScript Äڵ带 ¸í·ÉÁÙ Àμö¿¡¼­ ÁöÁ¤ÇÑ µð·ºÅ͸® °³Ã¼¸¦ sidHistory Ư¼ºÀ» Á¦°ÅÇÕ´Ï´Ù.
  1. Microsoft ¸Þ¸ðÀåÀ» ¿±´Ï´Ù.
  2. ´ÙÀ½ Äڵ带 º¹»çÇÏ¿© ¸Þ¸ðÀå ¹®¼­¿¡ ºÙ¿© ³Ö½À´Ï´Ù.
    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
        
    					
  3. C:\ClearSidHistory.vbs·Î ¹®¼­¸¦ ÀúÀåÇϽʽÿÀ.
  4. Äڵ带 ½ÇÇàÇϽʽÿÀ. ClearSidHistory.vbs »ç¿ë ´ÙÀ½°ú °°½À´Ï´Ù.
    ClearSidHistory.vbs - n cscript.exe¸¦ <name>= [- o = <objectcategory>] [- c = <objectclass>]

    -n < name ã°í °³Ã¼ÀÇ> =
    -o < objectCategory ã°í °³Ã¼ÀÇ > =
    -c = < ã°í °³Ã¼ÀÇ º¸¾È >

    ¿¹Á¦:

    ClearSidHistory.vbs - n cscript.exe¸¦ ³» ¿¬¶ôó =
    ClearSidHistory.vbs - n cscript.exe¸¦ ¼³Á¤À» -o = ÄÄÇ»ÅÍ =
    ClearSidHistory.vbs - n cscript.exe¸¦ James Smith-o = °³ÀÎ - c = »ç¿ëÀÚ =

¼Ó¼º

±â¼ú ÀÚ·á: 295758 - ¸¶Áö¸· °ËÅä: 2005³â 8¿ù 30ÀÏ È­¿äÀÏ - ¼öÁ¤: 3.2
º» ¹®¼­ÀÇ Á¤º¸´Â ´ÙÀ½ÀÇ Á¦Ç°¿¡ Àû¿ëµË´Ï´Ù.
  • Microsoft Windows 2000 Server
  • Microsoft Active Directory Service Interfaces 2.5
Ű¿öµå:?
kbmt kb32bitonly kbhowto kbprb KB295758 KbMtko
±â°è ¹ø¿ªµÈ ¹®¼­
Áß¿ä: º» ¹®¼­´Â Àü¹® ¹ø¿ª°¡°¡ ¹ø¿ªÇÑ °ÍÀÌ ¾Æ´Ï¶ó Microsoft ±â°è ¹ø¿ª ¼ÒÇÁÆ®¿þ¾î·Î ¹ø¿ªÇÑ °ÍÀÔ´Ï´Ù. Microsoft´Â ¹ø¿ª°¡°¡ ¹ø¿ªÇÑ ¹®¼­ ¹× ±â°è ¹ø¿ªµÈ ¹®¼­¸¦ ¸ðµÎ Á¦°øÇϹǷΠMicrosoft ±â¼ú ÀÚ·á¿¡ ÀÖ´Â ¸ðµç ¹®¼­¸¦ Çѱ۷ΠÁ¢ÇÒ ¼ö ÀÖ½À´Ï´Ù. ±×·¯³ª ±â°è ¹ø¿ª ¹®¼­°¡ Ç×»ó ¿Ïº®ÇÑ °ÍÀº ¾Æ´Õ´Ï´Ù. µû¶ó¼­ ±â°è ¹ø¿ª ¹®¼­¿¡´Â ¸¶Ä¡ ¿Ü±¹ÀÎÀÌ Çѱ¹¾î·Î ¸»ÇÒ ¶§ ½Ç¼ö¸¦ ÇÏ´Â °Íó·³ ¾îÈÖ, ±¸¹® ¶Ç´Â ¹®¹ý¿¡ ¿À·ù°¡ ÀÖÀ» ¼ö ÀÖ½À´Ï´Ù. Microsoft´Â ³»¿ë»óÀÇ ¿À¿ª ¶Ç´Â Microsoft °í°´ÀÌ ÀÌ·¯ÇÑ ¿À¿ªÀ» »ç¿ëÇÔÀ¸·Î½á ¹ß»ýÇÏ´Â ºÎ Á¤È®¼º, ¿À·ù ¶Ç´Â ¼ÕÇØ¿¡ ´ëÇØ Ã¥ÀÓÀ» ÁöÁö ¾Ê½À´Ï´Ù. Microsoft´Â ÀÌ·¯ÇÑ ¹®Á¦¸¦ ÇØ°áÇϱâ À§ÇØ ±â°è ¹ø¿ª ¼ÒÇÁÆ®¿þ¾î¸¦ ÀÚÁÖ ¾÷µ¥ÀÌÆ®Çϰí ÀÖ½À´Ï´Ù.

Çǵå¹é º¸³»±â