2016-08-23 65 views
0
$AppName = "MyAppName" 

#Open the store 
$AzStore = New-Object -COMobject AzRoles.AzAuthorizationStore 

#Access the App 
$MyApp = $AzStore.OpenApplication($AppName) 

任何人都可以幫助我完成此操作。如何在NetSqlAZMAN中獲取應用組,SID和用戶名

+0

我覺得這是阿茲曼代碼,打開store.New-對象-ComObject AzRoles.AzAuthorizationStore。誰能幫我用NetSqlAzman商店代碼? – Raaga

回答

0

您可能會發現這個例子有用:

# This internal function will download latest NetSqlAzMan.dll from NuGet (if necessary) 
# and import it into current runspace. 
# You can manually download installation package from netsqlazman.codeplex.com and 
# Add-Type it directly instead of this function 
function _DownloadAndImportLatestNetSqlAzManDll 
{ 
    $DownloadUrl = 'https://api.nuget.org/packages/netsqlazman-x86.3.6.0.15.nupkg' 
    $LocalDir = Join-Path $env:TEMP 'NetSqlAzManx86' 
    $LocalNupkg = Join-Path $LocalDir 'netsqlazman-x86.3.6.0.15.nupkg' 
    $DllPath  = Join-Path $LocalDir 'lib\net40\NetSqlAzMan.dll' 

    if (-not (Test-Path $LocalDir)) { 
     New-Item -Path $LocalDir -ItemType Directory -Force | Out-Null 
    } 

    if (-not (Test-Path $LocalNupkg)) { 
     Invoke-WebRequest -Uri $DownloadUrl -Method Get -OutFile $LocalNupkg | Out-Null 
    } 

    if (-not (Test-Path $DllPath)) { 
     Add-Type -AssemblyName System.IO.Compression.FileSystem 
     [System.IO.Compression.ZipFile]::ExtractToDirectory($LocalNupkg, $LocalDir) 
    } 

    Add-Type -Path $DllPath 
} 

_DownloadAndImportLatestNetSqlAzManDll 

# Initialization: 
$ConnectionString = 'Server=MySQLServerHostName; Database=NetSqlAzManStorage; Integrated Security=True' 
$AppStoreName  = 'MyAppStoreName' 
$AppName   = 'MyAppName' 
$AppGroupName  = 'MyAppGroupName' 
$AzStorage  = New-Object NetSqlAzMan.SqlAzManStorage($ConnectionString) 
$AzStore   = $AzStorage.GetStore($AppStoreName) 
$AzApp   = $AzStore.GetApplication($AppName) 

# Example usage: 

$UserName = '' 
$Members = $AzApp.GetApplicationGroup($AppGroupName).GetApplicationGroupAllMembers() 

"Members of application group $AppGroupName are:" 

foreach ($Member in $Members) 
{ 
    $Member.GetMemberInfo([ref] $UserName) | Out-Null 

    "User SID: $($Member.SID.StringValue)" 
    "User Display Name: $UserName" 
} 

# See NetSqlAzMan API reference: http://netsqlazman.codeplex.com/downloads/get/348377 

# Cleanup: 
$AzApp.Dispose() 
$AzStore.Dispose() 
$AzStorage.Dispose() 
相關問題