Principales respuestas
Convertir ForeignSecurityPrincipals a SAMAccountName

Pregunta
-
Buenos Dias
Actualmente tengo un dominio el cual tiene actualmente varias relaciones de confianza tipo External y otras cuantas que ya fueron eliminada al revisar el contenedor ForeignSecurityPrincipals veo que existen 3589 objetos y me gustaria conocer cuales son objetos por lo cual solicito de su ayuda para saber si puedo convertir ese SID en un nombre conocido
Gracias
Juan David Puerta
Respuestas
-
JUPUERTA,
¿Como estas? Aca te dejo un script de Powershell que convierte los SID a SAMAccountName:
http://gallery.technet.microsoft.com/scriptcenter/Convert-Foreign-Security-1fdbaf46
Function Convert-FspToUsername { <# .SYNOPSIS Convert a FSP to a sAMAccountName .DESCRIPTION This function converts FSP's to sAMAccountName's. .PARAMETER UserSID This is the SID of the FSP in the form of S-1-5-20. These can be found in the ForeignSecurityPrincipals container of your domain. .EXAMPLE Convert-FspToUsername -UserSID "S-1-5-11","S-1-5-17","S-1-5-20" sAMAccountName Sid -------------- --- NT AUTHORITY\Authenticated Users S-1-5-11 NT AUTHORITY\IUSR S-1-5-17 NT AUTHORITY\NETWORK SERVICE S-1-5-20 Description =========== This example shows passing in multipe sids to the function .EXAMPLE Get-ADObjects -ADSPath "LDAP://CN=ForeignSecurityPrincipals,DC=company,DC=com" -SearchFilter "(objectClass=foreignSecurityPrincipal)" | foreach {$_.Properties.name} |Convert-FspToUsername sAMAccountName Sid -------------- --- NT AUTHORITY\Authenticated Users S-1-5-11 NT AUTHORITY\IUSR S-1-5-17 NT AUTHORITY\NETWORK SERVICE S-1-5-20 Description =========== This example takes the output of the Get-ADObjects function, and pipes it through foreach to get to the name property, and the resulting output is piped through Convert-FspToUsername. .NOTES This function currently expects a SID in the same format as you see being displayed as the name property of each object in the ForeignSecurityPrincipals container in your domain. .LINK https://code.google.com/p/mod-posh/wiki/ActiveDirectoryManagement#Convert-FspToUsername #> [CmdletBinding()] Param ( [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] $UserSID ) Begin { } Process { foreach ($Sid in $UserSID) { try { $SAM = (New-Object System.Security.Principal.SecurityIdentifier($Sid)).Translate([System.Security.Principal.NTAccount]) $Result = New-Object -TypeName PSObject -Property @{ Sid = $Sid sAMAccountName = $SAM.Value } Return $Result } catch { $Result = New-Object -TypeName PSObject -Property @{ Sid = $Sid sAMAccountName = $Error[0].Exception.InnerException.Message.ToString().Trim() } Return $Result } } } End { } }
This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!
- Marcado como respuesta Uriel Almendra viernes, 4 de octubre de 2013 15:40
Todas las respuestas
-
JUPUERTA,
¿Como estas? Aca te dejo un script de Powershell que convierte los SID a SAMAccountName:
http://gallery.technet.microsoft.com/scriptcenter/Convert-Foreign-Security-1fdbaf46
Function Convert-FspToUsername { <# .SYNOPSIS Convert a FSP to a sAMAccountName .DESCRIPTION This function converts FSP's to sAMAccountName's. .PARAMETER UserSID This is the SID of the FSP in the form of S-1-5-20. These can be found in the ForeignSecurityPrincipals container of your domain. .EXAMPLE Convert-FspToUsername -UserSID "S-1-5-11","S-1-5-17","S-1-5-20" sAMAccountName Sid -------------- --- NT AUTHORITY\Authenticated Users S-1-5-11 NT AUTHORITY\IUSR S-1-5-17 NT AUTHORITY\NETWORK SERVICE S-1-5-20 Description =========== This example shows passing in multipe sids to the function .EXAMPLE Get-ADObjects -ADSPath "LDAP://CN=ForeignSecurityPrincipals,DC=company,DC=com" -SearchFilter "(objectClass=foreignSecurityPrincipal)" | foreach {$_.Properties.name} |Convert-FspToUsername sAMAccountName Sid -------------- --- NT AUTHORITY\Authenticated Users S-1-5-11 NT AUTHORITY\IUSR S-1-5-17 NT AUTHORITY\NETWORK SERVICE S-1-5-20 Description =========== This example takes the output of the Get-ADObjects function, and pipes it through foreach to get to the name property, and the resulting output is piped through Convert-FspToUsername. .NOTES This function currently expects a SID in the same format as you see being displayed as the name property of each object in the ForeignSecurityPrincipals container in your domain. .LINK https://code.google.com/p/mod-posh/wiki/ActiveDirectoryManagement#Convert-FspToUsername #> [CmdletBinding()] Param ( [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] $UserSID ) Begin { } Process { foreach ($Sid in $UserSID) { try { $SAM = (New-Object System.Security.Principal.SecurityIdentifier($Sid)).Translate([System.Security.Principal.NTAccount]) $Result = New-Object -TypeName PSObject -Property @{ Sid = $Sid sAMAccountName = $SAM.Value } Return $Result } catch { $Result = New-Object -TypeName PSObject -Property @{ Sid = $Sid sAMAccountName = $Error[0].Exception.InnerException.Message.ToString().Trim() } Return $Result } } } End { } }
This posting is provided "AS IS" with no warranties and confers no rights! Always test ANY suggestion in a test environment before implementing!
- Marcado como respuesta Uriel Almendra viernes, 4 de octubre de 2013 15:40
-
Buenos Dias
No me funciona, el Script lo guarde como FSP.ps1 y los estoy ejecutando desd PowerShell importando el modulo de AD y la ejecucion la estoy haciendo de la siguiente manera:
FSP.ps1 -UserSID S-1-5-21-1220945662-484763869-839522115-102082
pero no me arroja ningun resultado
Juan David Puerta
-
Desde un DC estoy ejecutando el siguiente comando
psgetsid.exe S-1-5-21-1220945662-484763869-839522115-101778 y el resultado que me arroja es:
Error querying SID:
No mapping between account names and security IDs was done.y en otros caso me arroja lo siguiente
psgetsid.exe S-1-5-21-1220945662-484763869-839522115-102082
Account for NOMBREDC\S-1-5-21-1220945662-484763869-839522115-102082:
Alias: DomainTrust\GRUPO071Entiendase DomainTrust como un dominio con el cual se tiene relacion de confianza
Juan David Puerta
-
Buenos Dias
Tengo una duda, supongo que para los que el resultado es:No mapping between account names and security IDs was done. quiere decir que ese usuario o grupo ya no existe en el dominio con el cual tengo relacion de confianza o que ya no exsite la relacion de confianza
Si es asi supongo que se podrian eliminar esos ID en ForeignSecurityPrincipals de manera normal o existe algun procedimiento para eliminarlos
Gracias
Juan David Puerta