Solved

Active Directory users into Infopath Drop down list box.

Posted on 2013-01-09
4
906 Views
Last Modified: 2013-07-23
hI,

I have Developed custom webservice to get AD users and got users list when I tried to invoke operation on server.

Then I created data connection in infopath form and added as external data source for a drop down list box but I didn't get any values into drop down box and I didn't get error either.

Can anybody please help me out to resolve this issue?

Any help would be appreciated.

Here I am adding my code, please let me know if I am doing some thing wrong.

public string GetProperty(SearchResult searchResult, string propertyName)
        {
            if (searchResult.Properties.Contains(propertyName))
            {
                return searchResult.Properties[propertyName][0].ToString();
            }
            else
            {
                return string.Empty;
            }
        }

        public DataTable CreateDataTable()
        {
            DataTable dtUsers = new DataTable();
            dtUsers.Columns.Add("UserName");
            return dtUsers;
        }
        [WebMethod]
        public DataSet GetActiveDirectoryUsers()
        {
            DirectoryEntry entry = null;
            DirectorySearcher searcher = null;
            DataSet dsUsers = null;

            try
            {
                DataTable dtUsers = new DataTable();
                dtUsers.Columns.Add("UserName");

                DataRow row1 = dtUsers.NewRow();
                row1["UserName"] = "ashok";
                dtUsers.Rows.Add(row1);
                dsUsers = new DataSet();
                dsUsers.Tables.Add(dtUsers);


                entry = new DirectoryEntry("LDAP://OU=XXX_USERS,OU=XX_XX,DC=XXXXX,DC=com");
                searcher = new DirectorySearcher(entry);
                //searcher.SearchScope=SearchScope.Subtree;
                searcher.Filter = "(&(objectClass=user))";
                SearchResultCollection resultColl = searcher.FindAll();
                if (resultColl.Count > 0)
                {
                    //DataTable dtUsers = new DataTable();
                    //dtUsers.Columns.Add("UserName");
                    foreach (SearchResult resultSet in resultColl)
                    {
                        if (!string.IsNullOrEmpty(GetProperty(resultSet, "title")) && !string.IsNullOrEmpty(GetProperty(resultSet, "Manager")))
                        {
                            DataRow row = dtUsers.NewRow();
                            row["UserName"] = GetProperty(resultSet, "Name");
                            dtUsers.Rows.Add(row);
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (searcher != null) searcher.Dispose();
                if (entry != null) entry.Dispose();
            }

            return dsUsers;
        }
0
Comment
Question by:aaedla
  • 2
  • 2
4 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 38761696
Hi,
have you tested your web service that it returns a dataset?

Please review the steps mentioned here
http://alekhyakodamsharepoint.wordpress.com/2012/05/03/infopath-2010-form-binding-data-to-dropdownlist-from-web-service/

HTH
Rainer
0
 

Author Comment

by:aaedla
ID: 38763037
Thank you Rainer for your comments.

I have tested web service and returned results.
I did exactly what "AlekhyaKodam" did, the only difference is I am trying to pull data from AD.

Regards.
0
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38764887
Hi,
where is your web service deployed? Dedicated web app? In the Sharepoint web services site/folder?
Perhaps its an authentication issue?
You might try to use Fiddler as a proxy (or Firefox/Firebug) and see what calls are going out from your client and what the service returns.
HTH
Rainer
0
 

Author Comment

by:aaedla
ID: 38765700
Rainer,

i have deployed in layouts folder(14\TEMPLATES\LAYOUTS\CustomWebService\webservice.asmx).

ok...let me try to use fiddler.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question