WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI LDAP CDO
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ADSI COM Example - Upload a Photo

 Keywords: AD ADSI ACtive Directory Upload Photo Jpg Jpeg OpenDSObject Put SetInfo

Question:

I´d like to know how can I upload photos to ActiveDirectory using Einbatch scripts. It´s possible ?

Answer:

Yes it is possible, if your AD schema provides a property to store the data. You could either use ADSI COM or use the ADSI extender. Here is an example using ADSI COM.
MyUser = "Roger Rabit"
jpgName = DirScript():"TestIn.JPG"
nBytes = FileSize(jpgName)
hImageSource = BinaryAlloc(nBytes)
BinaryRead( hImageSource, jpgName )
BinaryOleType(hImageSource, 303, 0, 0, 0)

objLdap = GetObject("LDAP:")
objUser = objLdap.OpenDSObject("LDAP://shamrock/CN=Roger Rabbit,CN=Users,DC=jclass,DC=org", "shamrock\GuessWho","*TopSecret*", 1)

ObjUser.Put("jpegPhoto", ARRAY:hImageSource)
ObjUser.SetInfo()
objUser = 0

Article ID:   W18049
Filename:   ADSI COM Example - Upload a Photo.txt
File Created: 2013:02:11:09:18:28
Last Updated: 2013:02:11:09:18:28