Skip to content

Instantly share code, notes, and snippets.

@norman-bauer
Last active April 13, 2018 07:20
Show Gist options
  • Save norman-bauer/06611244f8fe0c58940b2bd7846988fa to your computer and use it in GitHub Desktop.
Save norman-bauer/06611244f8fe0c58940b2bd7846988fa to your computer and use it in GitHub Desktop.
Upload a user picture from url to Active Directory with vbScript.
Function SavePictureToAdFromUrl(szADsPath, szUrl)
Dim objUser, bytesRead, adoStreamRead
Const adTypeBinary = 1
Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", szUrl, False
xml.Send
If xml.status = 200 Then
Set adoStreamRead = CreateObject("ADODB.Stream")
adoStreamRead.Type = adTypeBinary
adoStreamRead.Open
adoStreamRead.Write xml.responseBody
adoStreamRead.Position = 0
bytesRead = adoStreamRead.Read()
adoStreamRead.Close
Set objUser = GetObject(szADsPath)
objUser.Put "thumbnailPhoto", bytesRead
objUser.SetInfo
End If
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment