Hi Steve
In "NP_getNameLS" Lotus Script agent I have modified only "NP_findName" and "NP_findSelected". Also I have modified the Name Picker behaviour. It is like in outlook or domino address book now: you enter a letter it will display the first 95 persons that have the name starting with that letter, you enter the second letter it will display the first 95 persons that have the name starting with that two letters, etc. Some validations are performed due a lot of garbages that are in global AD. I do not think that it will be possible to use it like you use it now (search the names that contain a group of letters). Searching AD is like appying a filter…
Sub NP_findName(PAB As String,Key As String)
On Error Goto errorhandler<br/>
Dim agentLog As New NotesLog("Agent log")<br/>
Call agentLog.OpenAgentLog<br/>
Call agentLog.LogAction("Find Name ok vlad PAB=" + PAB + " Key=" + Key) <br/>
<br/>
Dim conn As Variant, cmd As Variant, result As Variant<br/>
<br/>
Const AD_SEARCH_ROOT_GLOBAL = "GC://dc=acme,dc=com" ' Host for global AD searches<br/>
Const GROUP_ATTRIBUTE_LIST = "showinaddressbook,DisplayName,mail,l,telephoneNumber,manager,Department,sAMAccountName, distinguishedName"<br/>
Call agentLog.LogAction("Step01 ")<br/>
<br/>
Set conn = CreateObject("ADODB.Connection")<br/>
Call conn.Open("Provider=ADsDSOObject;")<br/>
Set cmd = CreateObject("ADODB.Command")<br/>
Set cmd.ActiveConnection = conn<br/>
cmd.Properties("Page Size") = 100<br/>
Do <br/>
If stepf >=1 Then If Len(Key) = 1 Then Exit Sub Else Key = Mid$(Key, 1, Len(Key) - 1)<br/>
filter = "(DisplayName=" + Key + "*)"<br/>
cmdtxt$ = "<" & AD_SEARCH_ROOT_GLOBAL & ">;" & filter & ";" & GROUP_ATTRIBUTE_LIST & ";subtree"<br/>
cmd.CommandText = cmdtxt$ <br/>
Set result = cmd.Execute()<br/>
stepf = stepf + 1<br/>
Loop Until Not result.EOF<br/>
<br/>
Call agentLog.LogAction("Stepf: " + Cstr(Stepf))<br/>
Do While Not result.EOF<br/>
mgcount = mgcount + 1<br/>
If Isnull(result.Fields("showinaddressbook").value) Then UShow = "" Else UShow = result.Fields("showinaddressbook").value<br/>
isar = Isarray( UShow )<br/>
If isar Then<br/>
UsAMAccountName$ = result.Fields("sAMAccountName").value<br/>
UName$ = result.Fields("DisplayName").value<br/>
If Isnull(result.Fields("mail").value) Then UEmaddy$ = "" Else UEmaddy$= result.Fields("mail").value<br/>
If Isnull(result.Fields("l").value) Then ULocation$ = "" Else ULocation$ = result.Fields("l").value<br/>
If Isnull(result.Fields("telephoneNumber").value) Then UPhone$ = "" Else UPhone$ = result.Fields("telephoneNumber").value<br/>
If Isnull(result.Fields("manager").value) Then UManager$ = "" Else UManager$ = result.Fields("manager").value<br/>
If Isnull(result.Fields("Department").value) Then UDepartment$ = "" Else UDepartment$ = result.Fields("Department").value<br/>
mytext = ""<br/>
mytext = mytext+|name: "|+UName$ +|", |<br/>
mytext = mytext+|sname: "|+UsAMAccountName$ +|", |<br/>
mytext= mytext+|pab: "|+AD_SEARCH_ROOT_GLOBAL+|",|<br/>
mytext = mytext+|email: "|+UEmaddy$ +|", |<br/>
mytext = mytext+|location: "| + ULocation$ +|", | <br/>
mytext = mytext+|department: "| + UDepartment$ + |", |<br/>
mytext = mytext+|ophone: "|+UPhone$+|", |<br/>
mytext = mytext+|mphone: "|+UCellphonenumber$+|", |<br/>
mytext = mytext+|fax: "|+UOfficefaxphonenumber+|", | <br/>
mytext = mytext+|manager: "|+UManager$ +|"| <br/>
'Call agentLog.LogAction("i=" + Cstr(i) + " mytext: " + mytext)<br/>
'mytext = Replace(mytext, "'", "'")<br/>
Print |NP_names.push( { |+mytext+| } );|<br/>
End If<br/>
Call result.MoveNext()<br/>
If mgcount > 95 Then Exit Do <br/>
Loop<br/>
Exit Sub<br/>
ErrorHandler:
Call agentLog.LogAction("Error : " + Error())<br/>
' Print Error(), Err(), Erl()
' Msgbox( Error$ )
Exit Sub<br/>
End Sub
Sub NP_findSelected(PAB As String,Key As Variant)
Dim conn As Variant, cmd As Variant, result As Variant<br/>
<br/>
Const AD_SEARCH_ROOT_GLOBAL = "GC://dc=acme,dc=com" ' Host for global AD searches<br/>
Const GROUP_ATTRIBUTE_LIST = "DisplayName,mail,l,telephoneNumber,manager,Department,sAMAccountName, distinguishedName"<br/>
<br/>
Set conn = CreateObject("ADODB.Connection")<br/>
Call conn.Open("Provider=ADsDSOObject;")<br/>
Set cmd = CreateObject("ADODB.Command")<br/>
Set cmd.ActiveConnection = conn<br/>
cmd.Properties("Page Size") = 100<br/>
If stepf >=1 Then If Len(Key) = 1 Then Exit Sub Else Key = Mid$(Key, 1, Len(Key) - 1)<br/>
filter = "(mail=" + Key + ")"<br/>
cmdtxt$ = "<" & AD_SEARCH_ROOT_GLOBAL & ">;" & filter & ";" & GROUP_ATTRIBUTE_LIST & ";subtree"<br/>
cmd.CommandText = cmdtxt$ <br/>
Set result = cmd.Execute()<br/>
If Not result.EOF Then<br/>
mgcount = mgcount + 1<br/>
UName$ = result.Fields("DisplayName").value<br/>
If Isnull(result.Fields("mail").value) Then UEmaddy$ = "" Else UEmaddy$= result.Fields("mail").value<br/>
If Isnull(result.Fields("l").value) Then ULocation$ = "" Else ULocation$ = result.Fields("mail").value<br/>
If Isnull(result.Fields("telephoneNumber").value) Then UPhone$ = "" Else UPhone$ = result.Fields("telephoneNumber").value<br/>
If Isnull(result.Fields("manager").value) Then UManager$ = "" Else UManager$ = result.Fields("manager").value<br/>
If Isnull(result.Fields("Department").value) Then UDepartment$ = "" Else UDepartment$ = result.Fields("Department").value<br/>
mytext = ""<br/>
mytext = mytext+|name: "|+UName$ +|", |<br/>
mytext = mytext+|sname: "|+UName$ + " common " +|", |<br/>
mytext= mytext+|pab: "|+AD_SEARCH_ROOT_GLOBAL+|",|<br/>
mytext = mytext+|email: "|+UEmaddy$ +|", |<br/>
mytext = mytext+|location: "| + ULocation$ +|", | <br/>
mytext = mytext+|department: "| + UDepartment$ + |", |<br/>
mytext = mytext+|ophone: "|+UPhone$+|", |<br/>
mytext = mytext+|mphone: "|+UCellphonenumber$+|", |<br/>
mytext = mytext+|fax: "|+UOfficefaxphonenumber+|", | <br/>
mytext = mytext+|manager: "|+UManager$ +|"| <br/>
Print |NP_selectedPeople.push( { |+mytext+| } );|<br/>
End If<br/>
<br/>
End Sub