Question
GUI Affichage de données des users
- Philippe
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 1778
- Remerciements reçus 21
il y a 7 ans 3 mois #28104
par Philippe

n'oublie pas les sous fonctions comme Get-CurrentUser, tu lui passe objListView comme paramètre
Réponse de Philippe sur le sujet Re:[Résolu] GUI Affichage de données des users
la priorité c'est la santé, soigne toi biensorry j'étais malade ces derniers jours
bonne idéemon but c'est de devenir un initié chez vous
oui bonne idée il faut quand même créé/initialisé autant de variables que de form comme tu a déjà commencer à le faireJe trouve que le nombre de lignes du code augmente rapidement. Donc j'ai pensé le reduire en créant une fonction qui recoit des paramêtres et crée automatiquement les formes. que penses tu?
n'oublie pas les sous fonctions comme Get-CurrentUser, tu lui passe objListView comme paramètre
Connexion ou Créer un compte pour participer à la conversation.
- Philippe
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 1778
- Remerciements reçus 21
il y a 7 ans 3 mois #28116
par Philippe
Réponse de Philippe sur le sujet Re:[Résolu] GUI Affichage de données des users
salut hichammadd
a tu réussi à faire ce que tu voulais ?
a tu réussi à faire ce que tu voulais ?
Connexion ou Créer un compte pour participer à la conversation.
- Hicham Madini
- Auteur du sujet
- Hors Ligne
- Membre premium
-
Réduire
Plus d'informations
- Messages : 98
- Remerciements reçus 0
il y a 7 ans 3 mois #28120
par Hicham Madini
Réponse de Hicham Madini sur le sujet Re:[Résolu] GUI Affichage de données des users
slt 6ratgus,
non pas encore ca marche pas mais je continue.
J'ai aussi un soucis pour la recherche des groupes.
si je lance cette requette:
[code:1]$Domaine = \"LDAP://www.zflexldap.com:389/dc=zflexsoftware,dc=com\"
$DNN = \"cn=ro_admin,ou=sysadmins,dc=zflexsoftware,dc=com\"
$Pass = \"zflexpass\"
$Root = New-Object -TypeName System.DirectoryServices.DirectoryEntry($Domaine, $DNN, $Pass, 'FastBind')
$LDAP_Query = New-Object System.DirectoryServices.DirectorySearcher($Root,\"(&(objectclass=*)(cn=guestgrp1))\"«»)
$results= $LDAP_Query.findall()
$results.Properties.member[/code:1]
j'ai 5 membres comme resultat:
cn=nobody
cn=ro_admin,ou=sysadmins,dc=zflexsoftware,dc=com
uid=tonytest,ou=users,ou=developers,dc=zflexsoftware,dc=com
uid=khuong,ou=users,ou=developers,dc=zflexsoftware,dc=com
uid=khuong2,ou=users,ou=developers,dc=zflexsoftware,dc=com
mais quand je fait à partir de la Form il ne me montre que le premier membre.
voici le code que j'ai pour le moment.
[code:1][void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
[System.Windows.Forms.Application]::EnableVisualStyles()
####### ## Global Variables #######
# working hash table of groups being operated against (lookup results are stored in this)
$script:workingGroups = @{}
# list of fields to be included in results table and in detail form for individual account
$script:fieldsTable = @(\"cn\", \"description\"«»)
$script:fieldsDetail = @(\"cn\", \"description\", \"member\"«»)
# fieldsConfig is a hash of field names with an array of (numLines, scrollEnabled, textbox)
$script:fieldsConfig = [ordered]@{
\"cn\" = (1, $False, $Null);
\"description\" = (1, $False, $Null);
\"member\" = (8, $True, $Null)
}
# attribute mapping to field label
$script:attributesToFields = @{
\"cn\" = (\"cn\", $False);
\"description\" = (\"description\", $False);
\"member\" = (\"member\", $False);
}
$script:buttonWidth = 150
$script:buttonHeight = 23
$script:buttonBaseX = 620
#######
## Helper Functions
#######
function Get-Groups ($query = \"\"«») {
If ($query.Trim() -eq \"\"«») {
return @{}
}
$query = \"*\" + $query + \"*\"
$LDAP_Query = New-Object System.DirectoryServices.DirectorySearcher($Root, \"(&(objectclass=*)(cn=$query))\"«»)
$results = $LDAP_Query.findall()
$groups = @{}
ForEach ($result in $results) {
$group = @{}
ForEach ($attribute in $script:attributesToFields.Keys) {
If ($group.Keys -notContains $script:attributesToFields[$attribute][0]) {
#member attribute is a special case
If ($attribute -eq 'member') {
$result.properties[$attribute][0].keys = ($result.properties.$attribute.keys | Sort) -join \"`r`n\"
}
$group.Add($script:attributesToFields.$attribute[0], $result.properties[$attribute][0])
}
}
$groups.Add($result.properties.cn[0], $group)
}
return $groups
}
function Do-AccountLookup ($strQuery) {
$script:workingGroups = Get-Groups $strQuery
$objListView.Items.Clear()
$script:workingGroups.Keys | ForEach-Object {
$current_group = $_
$objListviewItem = New-Object System.Windows.Forms.ListViewItem($script:workingGroups.get_Item($current_group).get_Item($script:fieldsTable[0]))
ForEach ($field in $script:fieldsTable[1..($script:fieldsTable.Length - 1)]) {
$objListviewItem.SubItems.Add([string]$script:workingGroups.get_Item($current_group).get_Item($field)) | Out-Null
}
$objListview.Items.Add($objListviewItem) | Out-Null
}
}
#######
## GUI Event Handlers
#######
# handlers for static buttons
[System.EventHandler] $hndlrDoAccountLookup = {
$objListview.Items.Clear()
$Domaine = \"LDAP://www.zflexldap.com:389/dc=zflexsoftware,dc=com\"
$DNN = \"cn=ro_admin,ou=sysadmins,dc=zflexsoftware,dc=com\"
$Pass = \"zflexpass\"
$Root = New-Object -TypeName System.DirectoryServices.DirectoryEntry($Domaine, $DNN, $Pass, 'FastBind')
$query = $txtQuery.Text
Do-AccountLookup($query)
}
######### GUI Helpers #######
function Get-CurrentGroup () {
$currentGroup = $Null
$currentIdx = $objListView.SelectedIndices[0]
if ($currentIdx -ne $Null) {
$currentGroup = @{}
$currentcn = $objListView.SelectedItems[0].Text
$currentGroup.Add(\"Index\", $currentIdx)
ForEach ($attr in $script:fieldsConfig.Keys) {
$currentGroup.Add($attr, $script:workingGroups.$currentcn.$attr)
}
}
return $currentGroup
}
Function Do-RenderGroupDetail($currentGroup = $Null) {
if ($currentGroup -eq $Null) {
$currentGroup = Get-CurrentGroup
}
if ($currentGroup -ne $Null) {
$cn = $currentGroup.cn
foreach ($key in $script:fieldsDetail) {
if ($key -eq \"DN\"«») {
$script:fieldsConfig.Get_Item($key)[2].Text = $script:workingGroups.get_Item($cn).get_Item($key) -replace \"LDAP://ldap.forumsys.com:389/\", \"\"
}
else {
$script:fieldsConfig.Get_Item($key)[2].Text = $script:workingGroups.get_Item($cn).get_Item($key)
}
$script:fieldsConfig.Get_Item($key)[2].ReadOnly = $True
}
}
else {
foreach ($key in $script:fieldsDetail) {
$script:fieldsConfig.Get_Item($key)[2].Text = \"\"
}
}
}
function Sort-ListView {
# from etechgoodness.wordpress.com/2014/02/25/s...tview-in-powershell-
without-a-custom-comparer/
param([parameter(Position = 0)][UInt32]$Column)
$Numeric = $true # determine how to sort
if ($Script:LastColumnClicked -eq $Column) {
$Script:LastColumnAscending = -not $Script:LastColumnAscending
}
else {
$Script:LastColumnAscending = $true
}
$Script:LastColumnClicked = $Column
$ListItems = @(@(@())) # three-dimensional array; column 1 indexes the other columns,column 2 is the value to be
# sorted on, and column 3 is the System.Windows.Forms.ListViewItem object
foreach ($ListItem in $objListView.Items) {
# if all items are numeric, can use a numeric sort
if ($Numeric -ne $false) {
try {
$Test = [Double]$ListItem.SubItems.Text[$Column]
}
catch {
$Numeric = $false # a non-numeric item was found, so sort will occur as a string
}
}
$ListItems += , @($ListItem.SubItems.Text[$Column], $ListItem)
}
$EvalExpression = {
if ($Numeric)
{ return [Double]$_[0] }
else
{ return [String]$_[0] }
}
$ListItems = $ListItems | Sort-Object -Property @{Expression = $EvalExpression; Ascending = $Script:LastColumnAscending}
$objListView.BeginUpdate()
$objListView.Items.Clear()
foreach ($ListItem in $ListItems) {
$objListView.Items.Add($ListItem[1])
}
$objListView.EndUpdate()
}
#######
## GUI Initialization
#######
$frmUI = New-Object System.Windows.Forms.Form
$frmUI.Text = \"User Account Managment\"
$frmUI.Size = New-Object System.Drawing.Size(610, 400)
$frmUI.StartPosition = \"CenterScreen\"
$frmUI.KeyPreview = $True
$frmUI.MaximumSize = $frmUI.Size
$frmUI.MinimumSize = $frmUI.Size
# first row - lookup input / button
$lblQuery = New-Object System.Windows.Forms.Label
$lblQuery.Location = New-Object System.Drawing.Size(5, 5)
$lblQuery.Size = New-Object System.Drawing.Size(140, 20)
$lblQuery.Text = \"groupname:\"
$frmUI.Controls.Add($lblQuery)
$txtQuery = New-Object System.Windows.Forms.TextBox
$txtQuery.Location = New-Object System.Drawing.Size(145, 5)
$txtQuery.Size = New-Object System.Drawing.Size(270, 20)
$frmUI.Controls.Add($txtQuery)
$txtQuery.Select()
$btnLookup = New-Object System.Windows.Forms.Button
$btnLookup.Location = New-Object System.Drawing.Size(($buttonBaseX - $buttonWidth - 40), 5)
$btnLookup.Size = New-Object System.Drawing.Size($buttonWidth, $buttonHeight)
$btnLookup.Text = \"Lookup\"
$btnLookup.Add_Click($hndlrDoAccountLookup)
$frmUI.Controls.Add($btnLookup)
# second row - lookup results
$lblResult = New-Object System.Windows.Forms.Label
$lblResult.Location = New-Object System.Drawing.Size(5, 45)
$lblResult.Size = New-Object System.Drawing.Size(400, 15)
$lblResult.Text = \"Lookup Results\"
$frmUI.Controls.Add($lblResult)
$objListview = New-Object System.Windows.Forms.Listview
$objListview.Location = New-Object System.Drawing.Size(5, 60)
$objListview.Size = New-Object System.Drawing.Size(590, 140)
$objListview.Height = 140
$objListview.View = [System.Windows.Forms.View]::«»Details
$objListView.MultiSelect = $False
$objListView.FullRowSelect = $True
foreach ($field in $script:fieldsTable) {
$col = $objListview.Columns.Add($field)
$col.Width = 180
}
$objListView.add_ColumnClick( {Sort-ListView $_.Column})
$frmUI.Controls.Add($objListview)
$objListview.HideSelection = $False
$objListview.Add_SelectedIndexChanged( {Do-RenderGroupDetail})
# third row - individual account details
$lblAccount = New-Object System.Windows.Forms.Label
$lblAccount.Location = New-Object System.Drawing.Size(5, 210)
$lblAccount.Size = New-Object System.Drawing.Size(400, 15)
$lblAccount.Text = \"Account Details\"
$frmUI.Controls.Add($lblAccount)
$details_baseheight_Child = 30
$details_baseheight = 230
$details_rowheight = 25
$details_rowwidth = 480
# build out the text fields to hold the account details
$i = 0
ForEach ($fieldName in $script:fieldsDetail) {
$lbl = New-Object System.Windows.Forms.Label
$lbl.Location = New-Object System.Drawing.Size(5, ($details_baseheight + ($details_rowheight * $i)))
$lbl.Size = New-Object System.Drawing.Size(100, $details_rowheight)
$lbl.Text = $fieldName + \":\"
$frmUI.Controls.Add($lbl)
$txt = New-Object System.Windows.Forms.TextBox
$txt.Location = New-Object System.Drawing.Size(105, ($details_baseheight + ($details_rowheight * $i)))
$rows = $script:fieldsConfig.Get_Item($fieldName)[0]
$scrollable = $script:fieldsConfig.Get_Item($fieldName)[1]
$txt.Size = New-Object System.Drawing.Size($details_rowwidth, (15 * $rows))
$txt.ReadOnly = $True
if ($rows -gt 1) {
$txt.MultiLine = $True
}
if ($scrollable) {
$txt.ScrollBars = \"Vertical\"
}
$script:fieldsConfig.Get_Item($fieldName)[2] = $txt
$frmUI.Controls.Add($txt)
$i += 1
}
# misc gui stuff
$frmUI.Add_KeyDown( {if ($_.KeyCode -eq \"Enter\"«») {$hndlrDoAccountLookup.Invoke($Null, [EventArgs]::Empty)}})
$frmUI.Add_KeyDown( {if ($_.KeyCode -eq \"Escape\"«») {$frmUI.Close()}})
$frmUI.Add_Shown( {$frmUI.Activate()})
[void]$frmUI.ShowDialog()[/code:1]
Merci d'avance pour ton aide!<br><br>Message édité par: hichammadd, à: 12/02/19 14:54
non pas encore ca marche pas mais je continue.
J'ai aussi un soucis pour la recherche des groupes.
si je lance cette requette:
[code:1]$Domaine = \"LDAP://www.zflexldap.com:389/dc=zflexsoftware,dc=com\"
$DNN = \"cn=ro_admin,ou=sysadmins,dc=zflexsoftware,dc=com\"
$Pass = \"zflexpass\"
$Root = New-Object -TypeName System.DirectoryServices.DirectoryEntry($Domaine, $DNN, $Pass, 'FastBind')
$LDAP_Query = New-Object System.DirectoryServices.DirectorySearcher($Root,\"(&(objectclass=*)(cn=guestgrp1))\"«»)
$results= $LDAP_Query.findall()
$results.Properties.member[/code:1]
j'ai 5 membres comme resultat:
cn=nobody
cn=ro_admin,ou=sysadmins,dc=zflexsoftware,dc=com
uid=tonytest,ou=users,ou=developers,dc=zflexsoftware,dc=com
uid=khuong,ou=users,ou=developers,dc=zflexsoftware,dc=com
uid=khuong2,ou=users,ou=developers,dc=zflexsoftware,dc=com
mais quand je fait à partir de la Form il ne me montre que le premier membre.
voici le code que j'ai pour le moment.
[code:1][void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\"«»)
[System.Windows.Forms.Application]::EnableVisualStyles()
####### ## Global Variables #######
# working hash table of groups being operated against (lookup results are stored in this)
$script:workingGroups = @{}
# list of fields to be included in results table and in detail form for individual account
$script:fieldsTable = @(\"cn\", \"description\"«»)
$script:fieldsDetail = @(\"cn\", \"description\", \"member\"«»)
# fieldsConfig is a hash of field names with an array of (numLines, scrollEnabled, textbox)
$script:fieldsConfig = [ordered]@{
\"cn\" = (1, $False, $Null);
\"description\" = (1, $False, $Null);
\"member\" = (8, $True, $Null)
}
# attribute mapping to field label
$script:attributesToFields = @{
\"cn\" = (\"cn\", $False);
\"description\" = (\"description\", $False);
\"member\" = (\"member\", $False);
}
$script:buttonWidth = 150
$script:buttonHeight = 23
$script:buttonBaseX = 620
#######
## Helper Functions
#######
function Get-Groups ($query = \"\"«») {
If ($query.Trim() -eq \"\"«») {
return @{}
}
$query = \"*\" + $query + \"*\"
$LDAP_Query = New-Object System.DirectoryServices.DirectorySearcher($Root, \"(&(objectclass=*)(cn=$query))\"«»)
$results = $LDAP_Query.findall()
$groups = @{}
ForEach ($result in $results) {
$group = @{}
ForEach ($attribute in $script:attributesToFields.Keys) {
If ($group.Keys -notContains $script:attributesToFields[$attribute][0]) {
#member attribute is a special case
If ($attribute -eq 'member') {
$result.properties[$attribute][0].keys = ($result.properties.$attribute.keys | Sort) -join \"`r`n\"
}
$group.Add($script:attributesToFields.$attribute[0], $result.properties[$attribute][0])
}
}
$groups.Add($result.properties.cn[0], $group)
}
return $groups
}
function Do-AccountLookup ($strQuery) {
$script:workingGroups = Get-Groups $strQuery
$objListView.Items.Clear()
$script:workingGroups.Keys | ForEach-Object {
$current_group = $_
$objListviewItem = New-Object System.Windows.Forms.ListViewItem($script:workingGroups.get_Item($current_group).get_Item($script:fieldsTable[0]))
ForEach ($field in $script:fieldsTable[1..($script:fieldsTable.Length - 1)]) {
$objListviewItem.SubItems.Add([string]$script:workingGroups.get_Item($current_group).get_Item($field)) | Out-Null
}
$objListview.Items.Add($objListviewItem) | Out-Null
}
}
#######
## GUI Event Handlers
#######
# handlers for static buttons
[System.EventHandler] $hndlrDoAccountLookup = {
$objListview.Items.Clear()
$Domaine = \"LDAP://www.zflexldap.com:389/dc=zflexsoftware,dc=com\"
$DNN = \"cn=ro_admin,ou=sysadmins,dc=zflexsoftware,dc=com\"
$Pass = \"zflexpass\"
$Root = New-Object -TypeName System.DirectoryServices.DirectoryEntry($Domaine, $DNN, $Pass, 'FastBind')
$query = $txtQuery.Text
Do-AccountLookup($query)
}
######### GUI Helpers #######
function Get-CurrentGroup () {
$currentGroup = $Null
$currentIdx = $objListView.SelectedIndices[0]
if ($currentIdx -ne $Null) {
$currentGroup = @{}
$currentcn = $objListView.SelectedItems[0].Text
$currentGroup.Add(\"Index\", $currentIdx)
ForEach ($attr in $script:fieldsConfig.Keys) {
$currentGroup.Add($attr, $script:workingGroups.$currentcn.$attr)
}
}
return $currentGroup
}
Function Do-RenderGroupDetail($currentGroup = $Null) {
if ($currentGroup -eq $Null) {
$currentGroup = Get-CurrentGroup
}
if ($currentGroup -ne $Null) {
$cn = $currentGroup.cn
foreach ($key in $script:fieldsDetail) {
if ($key -eq \"DN\"«») {
$script:fieldsConfig.Get_Item($key)[2].Text = $script:workingGroups.get_Item($cn).get_Item($key) -replace \"LDAP://ldap.forumsys.com:389/\", \"\"
}
else {
$script:fieldsConfig.Get_Item($key)[2].Text = $script:workingGroups.get_Item($cn).get_Item($key)
}
$script:fieldsConfig.Get_Item($key)[2].ReadOnly = $True
}
}
else {
foreach ($key in $script:fieldsDetail) {
$script:fieldsConfig.Get_Item($key)[2].Text = \"\"
}
}
}
function Sort-ListView {
# from etechgoodness.wordpress.com/2014/02/25/s...tview-in-powershell-
without-a-custom-comparer/
param([parameter(Position = 0)][UInt32]$Column)
$Numeric = $true # determine how to sort
if ($Script:LastColumnClicked -eq $Column) {
$Script:LastColumnAscending = -not $Script:LastColumnAscending
}
else {
$Script:LastColumnAscending = $true
}
$Script:LastColumnClicked = $Column
$ListItems = @(@(@())) # three-dimensional array; column 1 indexes the other columns,column 2 is the value to be
# sorted on, and column 3 is the System.Windows.Forms.ListViewItem object
foreach ($ListItem in $objListView.Items) {
# if all items are numeric, can use a numeric sort
if ($Numeric -ne $false) {
try {
$Test = [Double]$ListItem.SubItems.Text[$Column]
}
catch {
$Numeric = $false # a non-numeric item was found, so sort will occur as a string
}
}
$ListItems += , @($ListItem.SubItems.Text[$Column], $ListItem)
}
$EvalExpression = {
if ($Numeric)
{ return [Double]$_[0] }
else
{ return [String]$_[0] }
}
$ListItems = $ListItems | Sort-Object -Property @{Expression = $EvalExpression; Ascending = $Script:LastColumnAscending}
$objListView.BeginUpdate()
$objListView.Items.Clear()
foreach ($ListItem in $ListItems) {
$objListView.Items.Add($ListItem[1])
}
$objListView.EndUpdate()
}
#######
## GUI Initialization
#######
$frmUI = New-Object System.Windows.Forms.Form
$frmUI.Text = \"User Account Managment\"
$frmUI.Size = New-Object System.Drawing.Size(610, 400)
$frmUI.StartPosition = \"CenterScreen\"
$frmUI.KeyPreview = $True
$frmUI.MaximumSize = $frmUI.Size
$frmUI.MinimumSize = $frmUI.Size
# first row - lookup input / button
$lblQuery = New-Object System.Windows.Forms.Label
$lblQuery.Location = New-Object System.Drawing.Size(5, 5)
$lblQuery.Size = New-Object System.Drawing.Size(140, 20)
$lblQuery.Text = \"groupname:\"
$frmUI.Controls.Add($lblQuery)
$txtQuery = New-Object System.Windows.Forms.TextBox
$txtQuery.Location = New-Object System.Drawing.Size(145, 5)
$txtQuery.Size = New-Object System.Drawing.Size(270, 20)
$frmUI.Controls.Add($txtQuery)
$txtQuery.Select()
$btnLookup = New-Object System.Windows.Forms.Button
$btnLookup.Location = New-Object System.Drawing.Size(($buttonBaseX - $buttonWidth - 40), 5)
$btnLookup.Size = New-Object System.Drawing.Size($buttonWidth, $buttonHeight)
$btnLookup.Text = \"Lookup\"
$btnLookup.Add_Click($hndlrDoAccountLookup)
$frmUI.Controls.Add($btnLookup)
# second row - lookup results
$lblResult = New-Object System.Windows.Forms.Label
$lblResult.Location = New-Object System.Drawing.Size(5, 45)
$lblResult.Size = New-Object System.Drawing.Size(400, 15)
$lblResult.Text = \"Lookup Results\"
$frmUI.Controls.Add($lblResult)
$objListview = New-Object System.Windows.Forms.Listview
$objListview.Location = New-Object System.Drawing.Size(5, 60)
$objListview.Size = New-Object System.Drawing.Size(590, 140)
$objListview.Height = 140
$objListview.View = [System.Windows.Forms.View]::«»Details
$objListView.MultiSelect = $False
$objListView.FullRowSelect = $True
foreach ($field in $script:fieldsTable) {
$col = $objListview.Columns.Add($field)
$col.Width = 180
}
$objListView.add_ColumnClick( {Sort-ListView $_.Column})
$frmUI.Controls.Add($objListview)
$objListview.HideSelection = $False
$objListview.Add_SelectedIndexChanged( {Do-RenderGroupDetail})
# third row - individual account details
$lblAccount = New-Object System.Windows.Forms.Label
$lblAccount.Location = New-Object System.Drawing.Size(5, 210)
$lblAccount.Size = New-Object System.Drawing.Size(400, 15)
$lblAccount.Text = \"Account Details\"
$frmUI.Controls.Add($lblAccount)
$details_baseheight_Child = 30
$details_baseheight = 230
$details_rowheight = 25
$details_rowwidth = 480
# build out the text fields to hold the account details
$i = 0
ForEach ($fieldName in $script:fieldsDetail) {
$lbl = New-Object System.Windows.Forms.Label
$lbl.Location = New-Object System.Drawing.Size(5, ($details_baseheight + ($details_rowheight * $i)))
$lbl.Size = New-Object System.Drawing.Size(100, $details_rowheight)
$lbl.Text = $fieldName + \":\"
$frmUI.Controls.Add($lbl)
$txt = New-Object System.Windows.Forms.TextBox
$txt.Location = New-Object System.Drawing.Size(105, ($details_baseheight + ($details_rowheight * $i)))
$rows = $script:fieldsConfig.Get_Item($fieldName)[0]
$scrollable = $script:fieldsConfig.Get_Item($fieldName)[1]
$txt.Size = New-Object System.Drawing.Size($details_rowwidth, (15 * $rows))
$txt.ReadOnly = $True
if ($rows -gt 1) {
$txt.MultiLine = $True
}
if ($scrollable) {
$txt.ScrollBars = \"Vertical\"
}
$script:fieldsConfig.Get_Item($fieldName)[2] = $txt
$frmUI.Controls.Add($txt)
$i += 1
}
# misc gui stuff
$frmUI.Add_KeyDown( {if ($_.KeyCode -eq \"Enter\"«») {$hndlrDoAccountLookup.Invoke($Null, [EventArgs]::Empty)}})
$frmUI.Add_KeyDown( {if ($_.KeyCode -eq \"Escape\"«») {$frmUI.Close()}})
$frmUI.Add_Shown( {$frmUI.Activate()})
[void]$frmUI.ShowDialog()[/code:1]
Merci d'avance pour ton aide!<br><br>Message édité par: hichammadd, à: 12/02/19 14:54
Connexion ou Créer un compte pour participer à la conversation.
- Hicham Madini
- Auteur du sujet
- Hors Ligne
- Membre premium
-
Réduire
Plus d'informations
- Messages : 98
- Remerciements reçus 0
il y a 7 ans 3 mois #28151
par Hicham Madini
Réponse de Hicham Madini sur le sujet Re:[Résolu] GUI Affichage de données des users
slt,
bon ca bloque toujours à ce point là
[code:1]If ($attribute -eq 'member') {
$result.properties[$attribute][0] = ($result.properties.$attribute.keys | Sort) -join \"`r`n\"
}[/code:1]
J'ai tout essayé aucune chance
j'ai remarqué que sur le script original (qui fonctionne sous AD), il a dû utiliser .attribute et non pas la variable .$attribute pour afficher les groupes!
pourquoi? il y a que dieu qui sait jusqu'à maintenant :-D
[code:1]If ($attribute -eq 'memberOf') {
$result.attribute = ($result.attribute.Keys | Sort) -join \"`r`n\"
}
$user.Add($script:attributesToFields[$attribute][0], $result.$attribute)[/code:1]<br><br>Message édité par: hichammadd, à: 12/02/19 15:02
bon ca bloque toujours à ce point là
[code:1]If ($attribute -eq 'member') {
$result.properties[$attribute][0] = ($result.properties.$attribute.keys | Sort) -join \"`r`n\"
}[/code:1]
J'ai tout essayé aucune chance
j'ai remarqué que sur le script original (qui fonctionne sous AD), il a dû utiliser .attribute et non pas la variable .$attribute pour afficher les groupes!
pourquoi? il y a que dieu qui sait jusqu'à maintenant :-D
[code:1]If ($attribute -eq 'memberOf') {
$result.attribute = ($result.attribute.Keys | Sort) -join \"`r`n\"
}
$user.Add($script:attributesToFields[$attribute][0], $result.$attribute)[/code:1]<br><br>Message édité par: hichammadd, à: 12/02/19 15:02
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.047 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- GUI Affichage de données des users