广告插件或实用工具,生成唯一的uidnumber / gidnumber

我正在寻找:

一个插件,将为新用户自动生成唯一的uidNumber属性值,并在创build时为新组创build唯一的gidNumber属性值。

一个可configuration的用户/组pipe理应用程序,可以生成上面的唯一值,并填充Linux集成所需的各种其他属性

我们现在正在使用一个本土的脚本和网页来做这一切,但我们正在寻找的东西,我们不必保持和一点点抛光。

任何人都知道一个适合这个账单的好工具吗?

谢谢!

我不知道任何现有的工具,实际上触发创build。 虽然像Nic提到的那样,但是假设有可能写一些可以做到的事情。

但是实际上,在已经自动化的stream程之外,用户/组织的创build频率如何? 如果他们还没有,那么现有的configurationstream程应该增加,以添加本TechNet博客文章中描述的相关RFC2307属性。 对于手动创build的散列函数,您可以以任意间隔运行脚本,查找缺less属性的对象并根据需要填充它们。

在我们的环境中,我们所运行的脚本每隔5分钟在保持PDC模拟器angular色的DC上运行。 但是,我们可以把它降到每分钟一次,而没有太多额外的影响。 我们还根据基于对象的SID的algorithm生成我们的UID / GID值,而不是简单的自动递增值。 它的好处是可以保证*域/森林之间的唯一性,我们不需要做任何查找来find下一个值,或者确保我们想要使用的值没有被使用。 如果你愿意,我可以发布这个function。 但是听起来你们可能已经拥有了自己的系统。

*保证=尽可能多的,你可以保证两个域不会创build相同的随机生成域ID。

编辑:通过请求,这里是我们用来从SID生成UID / GID的Powershell函数。

function Get-UidFromSid() { [CmdletBinding()] param( [Parameter(Mandatory=$true,Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)] [System.Security.Principal.SecurityIdentifier]$sid ) # convert sid to byte array $sidBytes = New-Object byte[] $sid.BinaryLength $sid.GetBinaryForm($sidBytes, 0) Write-Verbose ("SID bytes: $([System.BitConverter]::ToString($sidBytes))") # copy the sections we need $ridDomainBytes = New-Object byte[] 8 [System.Array]::Copy($sidBytes, 16, $ridDomainBytes, 0, 4) $ridUserBytes = New-Object byte[] 8 [System.Array]::Copy($sidBytes, 24, $ridUserBytes, 0, 4) Write-Verbose ("Domain portion: $([System.BitConverter]::ToString($ridDomainBytes))") Write-Verbose ("User portion: $([System.BitConverter]::ToString($ridUserBytes))") # fix endian'ness if necessary if (![System.BitConverter]::IsLittleEndian) { [System.Array]::Reverse($ridDomainBytes) [System.Array]::Reverse($ridUserBytes) } # convert the byte arrays to longs $ridDomain = [System.BitConverter]::ToInt64($ridDomainBytes, 0); $ridUser = [System.BitConverter]::ToInt64($ridUserBytes, 0); Write-Verbose "Domain(Int64) = $ridDomain, User(Int64) = $ridUser" # Now we're going to use the first 9 bits of the domain rid followed by the # first 22 bits of the user rid to make a single 31 bit integer (32-bit signed) # that will be the new unique UID value for this SID $ridDomain = ($ridDomain -band 0x1ff) -shl 22 $ridUser = $ridUser -band 0x3fffff Write-Verbose "Domain(Int64) = $ridDomain, User(Int64) = $ridUser" return ($ridDomain + $ridUser) <# .SYNOPSIS Calculate the UID value for a Windows SID. .DESCRIPTION This function duplicates Centrify's algorithm for generating unique UID values for Active Directory users and groups. The original algorithm was provided by Centrify and ported to PowerShell by Ryan Bolger. .PARAMETER sid The SecurityIdentifier (SID) object to calculate against. .OUTPUTS System.Int32 value of the resulting UID. .EXAMPLE Get-UidFromSid ([System.Security.Principal.SecurityIdentifier]'S-1-5-21-3040497277-3966670145-4188292625-1137') Calculate a UID from a fictional SID. .EXAMPLE Get-ADUser myuser | Get-UidFromSid Calculate a UID from an existing Active Directory user via pipeline input. #> } 

您可以从PowerShell脚本分配gidNumber属性。 要使其自动执行,请将脚本作为计划任务调用。 我写了一个名为Initialize-GroupGids的cmdlet,它为AD组分配唯一的gid,并可以为不同的环境定制参数。

但基本上,你可以在PowerShell中这样做。

 # Find the highest GID used on any group in the domain $highGid = Get-ADGroup -LDAPFilter "(gidNumber=*)" -Properties gidNumber | Measure-Object -Property gidNumber -Maximum | Select-Object -ExpandProperty Maximum # Avoid assigning GIDs below 1000 $highGid = [Math]::max( $highGid, 1000 ) # Find every security group without a gidNumber, and give it one. Get-ADGroup -LDAPFilter "(!gidNumber=*)" | ? {$_.GroupCategory -eq "Security"} | $groups | Set-ADGroup -Add @{ gidNumber=++$highGid } 

这很容易被用来与用户和uidNumbers一起工作。

如果您希望将uids / gids指定为即时分配,Microsoft将有一个有趣的技术说明,即通过LDAP侦听Active Directory中的更改通知 。 不过,我认为这对PowerShell来说太复杂了。