web-dev-qa-db-ja.com

作成時に一意のuidnumber / gidnumberを生成するADプラグインまたはユーティリティ

私はどちらかを探しています:

新規ユーザーの一意のuidNumber属性値と、作成時に新しいグループの一意のgidNumber属性値を自動生成するプラグイン。

上記の一意の値を生成し、Linux統合に必要な他のさまざまな属性を設定できる構成可能なユーザー/グループ管理アプリケーション

私たちが提示するのは、これらすべてを行うために自家製のスクリプトとWebページを使用していますが、維持する必要がなく、もう少し洗練されたものを探しています。

法案に合う良いツールを知っている人はいますか?

ありがとう!

6
jasonpvp

実際に作成時にトリガーされる既存のツールを知りません。ニックが述べたように、それを行うことができる何かを書くことは仮想的に可能です。

しかし現実的には、ユーザー/グループはすでに自動化されたプロセスの外で作成される頻度はどれくらいですか?まだ行っていない場合は、既存のプロビジョニングプロセスを拡張して、関連する RFC2307 属性も追加する必要があります このTechNetブログ投稿 。手動で作成されたストラグラーの場合、属性が欠落しているオブジェクトを探し、必要に応じてそれらを設定するスクリプトを任意の間隔で実行できます。

私たちの環境では、5分ごとにDCPDCエミュレーターの役割を保持しているスクリプトを実行します。しかし、おそらく1分に1回にドロップダウンすることもできます。追加の影響はほとんどありません。また、単純な自動インクリメント値ではなく、オブジェクトのSIDに基づくアルゴリズムからUID/GID値を生成します。これには、ドメイン/フォレスト間で一意であることが保証されている*という利点があります。次の値を見つけるため、または使用したい値がまだ使用されていないことを確認するためにルックアップを行う必要はありません。必要に応じてその関数を投稿できます。ただし、皆さんはすでに独自のシステムを持っているようです。そのために。

*保証=ランダムに生成された同じドメインIDで2つのドメインが作成されないことを保証できる限り。

編集:リクエストに応じて、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.
#>

}
3
Ryan Bolger

ここでの回答とSambaメーリングリストからインスピレーションを得て、UID/GID値を割り当てるADAMというツールを作成しました。

https://gitlab.com/JonathonReinhart/adam

現在(2019年6月)、これはLinuxでのみテストされており、Samba ActiveDirectoryドメインに対して実行されています。ただし、Windowsで実行されているか、Windows Active Directoryドメインに対して実行されている(または非常に近い)必要があります。

1

PowerShellスクリプトからgidNumber属性を割り当てることができます。自動化するには、スクリプトをスケジュールされたタスクとして呼び出します。 Initialize-GroupGids というコマンドレットを作成しました。このコマンドレットは、ADグループに一意のギッドを割り当て、パラメーターを使用してさまざまな環境に合わせてカスタマイズできます。

ただし、基本的には、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でも簡単に採用できます。

Uid/gidの割り当てを瞬時に行う場合、Microsoftには LDAPを介したActive Directoryからの通知の変更を聞く に関する興味深いテクニカルノートがあります。ただし、PowerShellには少し洗練されすぎていると思います。

1
Nic