Valnurat

Read of an AD attribute of Octet String syntax

17 posts in this topic

How do you read AD attribute: thumbnailPhoto and show the picture? It is a syntax of octet string.

I have no code for this.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites



Maybe this and the following posts help:

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-03 - Version 1.2.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I read it and I could see some code to retrive data, but how do I show the picture?

 

#include <AD.au3>
#include <File.au3>

_AD_Open()
If @error Then Exit
$ThumbNailPhoto = _AD_GetObjectAttribute(@UserName, "thumbnailPhoto")
If @error Then $ThumbNailPhoto = ""
_AD_Close()

 


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

No idea :(
But there are a lot of C# or PowerShell examples available on the web. Maybe one of them fits your needs.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-03 - Version 1.2.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

From what I was reading, the file format is jpg, so I would think it would be possible to either write to a file and/or use GDI+ to display it...but I also don't have the know-how to create a script (to do the GDI+ part at least.)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Probably not required but thought I'd share my solution.

#include <AD.au3>
Opt('ExpandVarStrings', 1)
_ADO_USERIMAGE()
Func _ADO_USERIMAGE()
    Local $oADO_USERIMAGE, $hOPN_THUMBNAIL
    Local $sPIC_USERIMAGE = '@AppDataDir@\Microsoft\Windows\AccountPictures\UserTile.jpg'
    _AD_Open()
        $oADO_USERIMAGE = _AD_GetObjectAttribute(@UserName, 'thumbnailPhoto')
            If @error Then Exit
        $hOPN_THUMBNAIL = FileOpen($sPIC_USERIMAGE, 26)
        FileWrite($hOPN_THUMBNAIL, $oADO_USERIMAGE)
        FileClose($hOPN_THUMBNAIL)
    _AD_Close()
EndFunc

 

Edited by Subz
Updated Code

Share this post


Link to post
Share on other sites

Great solution :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-03 - Version 1.2.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Sorry for my very late reply, but how do I use that function?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

Subz's function grabs the thumbnailPhoto property and writes it to "@AppDataDir@\Microsoft\Windows\AccountPictures\UserTile.jpg".

No parameters needed. Just call the function.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-03 - Version 1.2.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

No "usertitle.jpg" file is created in "@AppDataDir@\Microsoft\Windows\AccountPictures"

 

Is this correct:
"@AppDataDir@" ?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#11 ·  Posted

aha.

 

Local $sPIC_USERIMAGE = @AppDataDir & '\Microsoft\Windows\AccountPictures\UserTile.jpg'


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#12 ·  Posted

Sorry forgot to put in 

Opt('ExpandVarStrings', 1) which allows you to use @AppDataDir in a string like "@AppDataDir@\Microsoft\Windows\AccountPictures\UserTile.jpg".

Share this post


Link to post
Share on other sites

#13 ·  Posted

Check.

It works now.

Is only possible to save this to a file? It can't be save in memory to show in GUICtrlCreatePic?

Thank you.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#14 ·  Posted

You probably could using GDI+ but haven't tried myself, you can use GuiCtrlCreatePic("@AppDataDir@\Microsoft\Windows\AccountPictures\UserTile.jpg", ....)

Share this post


Link to post
Share on other sites

#15 ·  Posted

Yes, but I would like, if possible, to "save" the picture in the RAM and then use the RAM as the source.

Is that possible?


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

#16 ·  Posted

Using the _GDIPlus_BitmapCreateFromMemory example works for me.

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <AD.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 300, $iHeight = 300, $iBgColor = 0xFFE8FF ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hBitmap = _GDIPlus_BitmapCreateFromMemory(_ADO_USERIMAGE()) ;load binary saved GIF image and convert it to GDI+ bitmap format
    Local $iW = _GDIPlus_ImageGetWidth($hBitmap), $iH = _GDIPlus_ImageGetHeight($hBitmap)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, ($iWidth - $iW) / 2, ($iHeight - $iH) / 2) ;display image in GUI

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func _ADO_USERIMAGE()
    _AD_Open()
        Local $oADO_USERIMAGE = _AD_GetObjectAttribute(@UserName, 'thumbnailPhoto')
            If @error Then Exit
    _AD_Close()
    Return $oADO_USERIMAGE
EndFunc

 

Share this post


Link to post
Share on other sites

#17 ·  Posted

Good lord.

 

Thank you.


Yours sincerely

Kenneth.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Valnurat
      By Valnurat
      I have a mainform with a ListviewControl. The ListView contains data from my SQL Server. My idea is that when you find what you are looking for, in the listview, I pick it by pressing the enter button and then show the content on a child window with some control.
      So my questions are:
      How do you pick the content in the listview with either enter button or the mouse?
      How do you create a child windows with control?
      Global $idListview, $idOKay _FormCreate() _Main() Func _FormCreate() ; Create GUI GUICreate("Computer Asset", 1027, 400) $idListview = GUICtrlCreateListView("", 2, 2, 1024, 268,Default, BitOR($LVS_SHOWSELALWAYS, $LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT)) ; Add columns _GUICtrlListView_AddColumn($idListview, "Computername", 100,2) _GUICtrlListView_AddColumn($idListview, "Tkt No.", 100,2) _GUICtrlListView_AddColumn($idListview, "Req No.", 100,2) _GUICtrlListView_AddColumn($idListview, "Order Date", 100,2) _GUICtrlListView_AddColumn($idListview, "Costcenter", 100,2) _GUICtrlListView_AddColumn($idListview, "Username", 100,2) _GUICtrlListView_AddColumn($idListview, "Model", 100,2) _GUICtrlListView_AddColumn($idListview, "Current Location", 100,2) _GUICtrlListView_AddColumn($idListview, "Option", 100,2) _GUICtrlListView_AddColumn($idListview, "Shipdate", 100,2) $idOKay = GUICtrlCreateButton("OK", 310, 290, 85, 25) GUISetState(@SW_SHOW) EndFunc Func _Main() Local $sConnectionString = 'DRIVER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & $sUser & ';PWD=' & $sPassword & ';' Local $oConnection = _ADO_Connection_Create() _ADO_Connection_OpenConString($oConnection, $sConnectionString) If @error Then Return SetError(@error, @extended, $ADO_RET_FAILURE) Local $sTableName = 'StaffMemberUser.ComputerAsset' Local $sQUERY = "Select Computername, TktNo, ReqNo, OrderDate, CostCenter, Username, Model, CurrentLocation, Note, Shipdate from " & $sTableName Local $oRecordset = _ADO_Execute($oConnection, $sQUERY) Local $aRecordsetArray = _ADO_Recordset_ToArray($oRecordset, False) Local $aRecordset_inner = _ADO_RecordsetArray_GetContent($aRecordsetArray) _GUICtrlListView_SetItemCount($idListview, UBound($aRecordset_inner) - 1) _GUICtrlListView_AddArray($idListview, $aRecordset_inner) ; CleanUp $oRecordset = Null _ADO_Connection_Close($oConnection) $oConnection = Null ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idOKay MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead($idListview), 2) Case $idListview MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2) EndSwitch WEnd GUIDelete() EndFunc  
    • tcox8
      By tcox8
      Hello,
      Currently I am running a script that calls a powershell script. To read the results of that I am reading StdOut. I am parsing things accordingly but unfortunately it doesn't parse correctly all the time and I end up missing parts of the string or other problems. My question then is, what is the best results for reading what is returned when running a powershell script or something similar?
    • Valnurat
      By Valnurat
      I hope my title is good enough.
      I'm using the ADO UDF and I have question regarding editing SQL records with this UDF.
      The owner of the UDF suggested an idea, but maybe there is another trix.
    • Valnurat
      By Valnurat
      I have a SQL db. I would like to view the content in a control. Like a table. The control should have the option to show every 2nd line in another color. When you pick a "cell" it should pick the whole row. When you dobbelt click on the row another windows should popup with the content from the row.
      What view control can do that?
    • Valnurat
      By Valnurat
      How do I access a sql database for inserting and reading?