Páginas

Como adicionar um atributo ao Schema do AD

Passo a passo para adicionar um novo atributo ao Schema do Active Directory.

1- Acesse o servidor Active Directory que roda a FSMO Schema Master, é necessário instalar a dll engine Schema com o comando:

regsvr32 schmmgmt.dll




2- Clique em OK




3- Depois abra o executar e digite MMC


4- Na console MCC selecione a opção Attribute e depois Create Attribute.




5- Para a criação de um novo atributo é necessário saber o OID está sendo utilizado pelo ambiente.
Para isso copie o código vbs abaixo no notepad e salve no desktop como rootOID.vbs, depois execute o mesmo.

' oidgen.vbs
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
' OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
' FITNESS FOR A PARTICULAR PURPOSE.'
' Copyright (c) Microsoft Corporation. All rights reserved'
' This script is not supported under any Microsoft standard support program or service.
' The script is provided AS IS without warranty of any kind. Microsoft further disclaims all
' implied warranties including, without limitation, any implied warranties of merchantability
' or of fitness for a particular purpose. The entire risk arising out of the use or performance
' of the scripts and documentation remains with you. In no event shall Microsoft, its authors,
' or anyone else involved in the creation, production, or delivery of the script be liable for
' any damages whatsoever (including, without limitation, damages for loss of business profits,
' business interruption, loss of business information, or other pecuniary loss) arising out of
' the use of or inability to use the script or documentation, even if Microsoft has been advised
' of the possibility of such damages.
' ----------------------------------------------------------------------Function GenerateOID()
'Initializing VariablesDim guidString, oidPrefix
Dim guidPart0, guidPart1, guidPart2, guidPart3, guidPart4, guidPart5, guidPart6
Dim oidPart0, oidPart1, oidPart2, oidPart3, oidPart4, oidPart5, oidPart6
On Error Resume Next'Generate GUID
Set TypeLib = CreateObject("Scriptlet.TypeLib")
guidString = TypeLib.Guid'If no network card is available on the machine then generating GUID can result with an error.
If Err.Number <> 0 Then
Wscript.Echo "ERROR: Guid could not be generated, please ensure machine has a network card."
Err.Clear
WScript.Quit
End If
'Stop Error Resume Next
On Error GoTo 0'The Microsoft OID Prefix used for the automated OID Generator
oidPrefix = "1.2.840.113556.1.8000.2554"'Split GUID into 6 hexadecimal numbers
guidPart0 = Trim(Mid(guidString, 2, 4))
guidPart1 = Trim(Mid(guidString, 6, 4))
guidPart2 = Trim(Mid(guidString, 11, 4))
guidPart3 = Trim(Mid(guidString, 16, 4))
guidPart4 = Trim(Mid(guidString, 21, 4))
guidPart5 = Trim(Mid(guidString, 26, 6))
guidPart6 = Trim(Mid(guidString, 32, 6))'Convert the hexadecimal to decimal
oidPart0 = CLng("&H" & guidPart0)
oidPart1 = CLng("&H" & guidPart1)
oidPart2 = CLng("&H" & guidPart2)
oidPart3 = CLng("&H" & guidPart3)
oidPart4 = CLng("&H" & guidPart4)
oidPart5 = CLng("&H" & guidPart5)
oidPart6 = CLng("&H" & guidPart6)'Concatenate all the generated OIDs together with the assigned Microsoft prefix and return
GenerateOID = oidPrefix & "." & oidPart0 & "." & oidPart1 & "." & oidPart2 & "." & oidPart3 & _
"." & oidPart4 & "." & oidPart5 & "." & oidPart6
'Output the resulted OID with best practice infoWscript & _
Wscript.Echo "Your root OID is: " & VBCRLF & GenerateOID & VBCRLF & VBCRLF & VBCRLF




6- Copie esse OID


7- Com o OID em mãos, coloque os dados do atributo que deseja e mais o OID, no final desse OID insira .1 (se for criar outros coloque .2, .3... e assim por diante)




8- Clique OK para finalizar


9- Depois selecione Classes no MMC e navegue até User e com o botão direito selecione a opção Properties




10 - Localize o atributo que você criou e clique em OK




11- Vá em services.msc e reinicie o serviço Active Directory Domain Services


12 - Por fim abra Users and Computers, vá até View e depois selecione a opção Advanced Features




13- Navegue até OU Users, selecione um usuário qualquer e com o botão direito selecione a opção Properties. Navegue até a guia Attribute Editor e confirme que o valor é apresentado.