Last active
April 13, 2018 07:20
-
-
Save norman-bauer/06611244f8fe0c58940b2bd7846988fa to your computer and use it in GitHub Desktop.
Upload a user picture from url to Active Directory with vbScript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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