Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 850
  • Last Modified:

InfoPath 2003 and Active Directory

All,

Is there a way to use InfoPath to find a first and last name from Active Directory given a user ID?  I have tried the GetUserProfile service from SharePoint but I have not been able to get the attributes needed except for the person completing the form.

I need to be able to allow a user to enter a LAN ID and then get the last and first names associated with the ID.  I am open to using wither AD or GetUersProfile but all I have been able to find is information about the person completing the form.  

Thanks.

0
MartePalmer
Asked:
MartePalmer
1 Solution
 
Clay FoxDirector of Business IntegrationCommented:
I think an AD web service is the best method.

You can ID the form user.

Query all of their AD attributes such as email, Manager, department, etc.

Also you can then query other users too.

There are several around, I have used the one from www.qdabra.com

You also then do not need any code or anything to use them.  The only trick is that you need a server to host the webservice. Another benefit, over local lookups, is that this works on VPN and remote connections since it is using their domain credentials not local ones.
0
 
MartePalmerAuthor Commented:
I found the code my modifying some scripts from microsoft and applying through a OnChageAfter script.  So how would i have it execute for every new record in a table?  Any ideas?

Here is the code
Sub msoxd_my_Prefix_OnAfterChange(eventObj)
 
    empid = XDocument.DOM.selectSingleNode("//my:Prefix").Text
    On Error Resume Next
    Const ADS_SCOPE_SUBTREE = 2
 
    Set oRootDSE = GetObject("LDAP://rootDSE")
    Set oConnection = CreateObject("ADODB.Connection")
    Set oCommand =   CreateObject("ADODB.Command")
    oConnection.Provider = "ADsDSOObject"
    oConnection.Open "Active Directory Provider"
    Set oCommand.ActiveConnection = oConnection
 
    oCommand.CommandText = "<LDAP://" & oRootDSE.Get("defaultNamingContext") & _
      ">;(&(objectCategory=User)(sAMAccountName=" & empid & "));givenname, & _
      sn, department;subtree"
        
    Set oRecordSet = oCommand.Execute
    XDocument.DOM.selectSingleNode("//my:FirstName").Text = oRecordSet.fields("givenname")
    XDocument.DOM.selectSingleNode("//my:LastName").Text = oRecordSet.fields("sn")
    XDocument.DOM.selectSingleNode("//my:UnitCode").Text = left(oRecordSet.fields("department"), 5)
	
    oConnection.Close
    Set oRecordSet = Nothing
    Set oCommand = Nothing
    Set oConnection = Nothing
    Set oRootDSE = Nothing
	
If eventObj.IsUndoRedo Then
	Exit Sub
End If
 
End Sub

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now