Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2006

Tip: Looking for answers? Try searching our database.

dropdown and ADSI

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Noel - 14 Aug 2006 11:00 GMT
Hi!

Is it possible to populate a dropdown list with ADSI users list?

Here's my current idea...

if XDocument.IsNew then
 set objUser = GetObject("WinNT://petnet/Domain Users")
 for each member in objUser.members
   fullname = objUser.Fullname
  ... ? (no idea to bind the items to dropdown)

 next
end if

Thanks in advance!
S.Y.M. Wong-A-Ton - 14 Aug 2006 11:37 GMT
Option 1:
Create a repeating group/field in the Main data source of your form, bind
your dropdown list to it (through its Properties dialog box), then fill the
XML for the repeating group in code with the names of your ADSI users.

Your loop is good. After adding the repeating group to the Main data source,
you just need to retrieve the main node of the repeating group and then in
your loop add child nodes to the main group node with each child node's value
containing the name of a user.

Option 2:
You could also create a (mockup/dummy) XML file with a structure for your
user names, then bind the dropdown list to the XML file (= secondary data
source), retrieve the XML of the secondary data source's DOM in code and add
your user names as childnodes to it as rows.

The first option would save your usernames in the form's XML if the form is
saved, the second option would not persist the usernames.
---
S.Y.M. Wong-A-Ton

> Hi!
>
[quoted text clipped - 12 lines]
>
> Thanks in advance!
Ben Walters - 15 Aug 2006 00:37 GMT
Hey Noel,
There are the options that were noted earlier, accessing a file and placing
the data in a repeating section howver if the list of users is large then
this could slow the performance of you form. Another option would be to use
a web service to return the ADSI users to the drop down list.

Hope this Helps
Cheers
Ben

> Hi!
>
[quoted text clipped - 12 lines]
>
> Thanks in advance!
Ash - 15 Aug 2006 02:51 GMT
Hi Ben,

Do you have any sample code to bind Drop down list to the list of users
returned from a web service? Or do you have any other idea to do this?
I am struggling with binding this DD box to the AD users list?

My current code on Infopath OnLoad event is

Dim nodeusers As IXMLDOMNode =
thisXDocument.DOM.selectSingleNode("my:myFields/my:users")
Dim ds As DirectorySearcher = New DirectorySearcher
ds.SearchRoot = New DirectoryEntry("")
ds.Filter = GetFilterString()
ds.PropertyNamesOnly = True
ds.PropertiesToLoad.Add("name")
ds.SearchScope = SearchScope.OneLevel

'// (CacheResults) property by default is true
ds.CacheResults = True
ds.ReferralChasing = ReferralChasingOption.None
ds.Sort = New SortOption("name", SortDirection.Ascending)

         '// start searching
           Dim src As SearchResultCollection = ds.FindAll()
           nodeusers.text = src.Count.ToString()
           Dim sr As SearchResult

           For Each sr In src
                       'Struggling at this point
                       nodeusers.text = sr.GetDirectoryEntry.ToString
           Next

Private Function FormFilter(ByVal objectCategory As String, ByVal
filter As String)
           Dim result As String
           result = String.Format("(&(objectCategory={0})(name={1}))",
objectCategory, filter)
           Return result
       End Function

       Private Function GetFilterString() As String

          Dim filter As String = ""
           filter += FormFilter("user", "*")
           Return "(|" + filter + ")"
       End Function

Thanks in advance.
Ashwani

> Hey Noel,
> There are the options that were noted earlier, accessing a file and placing
[quoted text clipped - 22 lines]
> >
> > Thanks in advance!
Noel - 15 Aug 2006 07:46 GMT
Thanks alot on your replies. I'll try it now.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.