This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


May 11, 2015, 6:19 PM
13 Posts

Download photos from Active Directory with Lotusscript

  • Category: Domino Designer
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags: ibm_notes,photos,active_directory,lotusscript
  • Replies: 8

I have created a Lotussscript that makes an LDAP query against Active Directory to get the first name, last name, department, phone, mobile and email for all users within a given department.

For each person I create a Notes document where I save this information. It is then displayed on a web page with HTML formatting.

However, I would also love to have the user photo in this list. In Power Shell I managed to figure out how to get the photo when I created a similar solution a few years back. But I can't for the life of me figure how to get the photo in Lotusscript. I want to store the photo in a rich text field, and then use it on the web page.

Has anyone done this? I am able to get hold of the photo attribute in the LDAP query. But doing a thumbnailphoto.value, like I do on a field like mobile.value, only returns an error (which I guess is because it's not a text but a photo).

Any help here would be appreciated

May 11, 2015, 6:24 PM
11 Posts
Handle it as a file/attachment
Hello Hogne,

I would suggest you to download the actual photo/picture from Active Directory, if that is possible, then attach it to the Notes document. I think you won't be able to view the file directly from Active Directory once it would need a HTTP server to actually display it, which you will have in Domino.

HTH. Regards,

Edson Luis Almeida Viana
May 11, 2015, 7:11 PM
13 Posts
Trying to download

Hi, Edson.

Thanks for your reply.

Sorry for not being clear about this, but I am actually trying to download it from AD, and then attach it to the Notes/Document. I was hoping this could be done when getting all the other data about the user from AD.

Here's my code:

    Set dbCurrent = s.Currentdatabase
    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=ADsDSOObject;"
    'test = objConnection.DefaultDatabase

    Set objCommand = CreateObject("ADODB.Command")
    Set objCommand.ActiveConnection = objConnection
    
    strLdapFilter = "Select sn, givenName, mail, telephoneNumber, mobile, department, employeeID, manager, thumbNailPhoto, sAMAccountName FROM 'LDAP://ou=" & strDepartment & ",ou=Users and Groups,ou=<town>,dc=<domain>,dc=com' WHERE objectCategory='person' AND objectClass='user'"

    objCommand.CommandText = strLdapFilter
    Set objRecordSet = objCommand.Execute

    If objRecordSet.RecordCount = 0 Then
        MsgBox "No groups found!"
    Else
        While Not objRecordset.EOF
            Set docPerson = dbCurrent.Createdocument()
            docPerson.Form = "frmEmployee"
            docPerson.sn= objRecordset.Fields("sn").value
            docPerson.givenName = objRecordset.Fields("givenName").value
            docPerson.department = objRecordset.Fields("department").value
            docPerson.telephonenumber = objRecordset.Fields("telephoneNumber").value
            docPerson.mobile = objRecordset.Fields("mobile").value
            docPerson.mail = objRecordset.Fields("mail").value

 

Here is where I'm trying to get hold of the photo, and attach it to the Notes Document:
            'Set rtItem = New NotesRichTextItem(docPerson, "thumbNailPhoto")
            'Set object = rtItem.EmbedObject(EMBED_OBJECT, "", objRecordset.Fields("thumbNailPhoto"))

The above didn't work, so I then tried this:

            Dim filenum As Integer
            Dim filename As String
            Dim varPhoto As Variant
            Set varPhoto = objRecordset.Fields("thumbNailPhoto")
            filename = "C:\user_icons\test.jpg" ' & objRecordset.Fields("sAMAccountName").value
            filenum% = FreeFile()
            Open filename For Binary Access Write As fileNum%
            'Put #filenum%, , varPhoto
            Put #filenum%, , filenum
            Close filenum%
            Call docPerson.Save(True,False,True)
            
            objRecordset.MoveNext
        Wend

No dice so far. Any ideas? Is it even possible?

May 11, 2015, 7:31 PM
11 Posts
Found something on MS Technet Forum that may help you
Hello Hogne,

This is what I found:

https://social.technet.microsoft.com/Forums/scriptcenter/en-US/1fac22c6-536f-4b4f-a272-79f10642990e/help-stuck-with-vbs-ad-query-that-save-files-from-thumbnailphoto-into-bmp-file-it-doesnt-go-threw?forum=ITCG

It seems (mainly on the responses to that topic) that downloading the photo is an option. When you have it on a file system, you may attach it to a Notes document using a LotusScript.


I think it would be easier if there was a way to publish the photo directly from AD using HTTP... maybe there is a plugin on IIS that you could use for it. Then I think it would not be so difficult to place the URL to the photo on a Notes document, maybe on a <image> HTML tag.

HTH. Regards,

Edson Luis Almeida Viana
May 12, 2015, 9:59 AM
13 Posts
Possible in Lotusscript?

@Edson: That looks exactly what I'm after, only in Lotusscript Thanks.

I will check the VB code to see if I can "translate" it into LS, I know they are quite similar, but it seems that there is stuff going on here that would not be possible with LS.

Any ideas or tips are appreciated.

May 12, 2015, 1:00 PM
11 Posts
Please, reply to your post if you still find any issues :) <eom>
May 12, 2015, 3:03 PM
13 Posts
Can't figure out how to do this in Lotusscript

I've been going through the VB -code now, and I understand it.

However, I'm not able to do this via LS. I just don't understand how to get the file from AD and down to the disk on the server where I'm running the script.

 

May 12, 2015, 10:00 AM
13 Posts
Getting hold of the photo

@Barry: Thanks, but getting photos IN to the field is not the problem. My problem is getting hold of the photo and downloading it from AD.


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal