How to pull Active Directory information about current user from Infopath


I am new to Infopath. I have this requirement that when I open the Infopath form, fields like ID, Name, Department etc should pull in data automatically from Active Directory. Could someone help?

thanks in advance,
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Clay FoxDirector of Business IntegrationCommented:
Several ways at this.
InfoPath has a builtin function called Username() which returns the local account name.
If you have an HR system or other record then you can use that to look up additional information.

SharePoint has a getuserprofile web service which will return the basic information which is synced from AD. has an AD webservice which will allow you to query anything in AD without code or anything.  You may need this if you are using custom fields in AD.

Hope that gets you started.
j1981Author Commented:
"SharePoint has a getuserprofile web service which will return the basic information which is synced from AD." -- I think this is the solution that may work.

Could you guide me further on how to go about this? thank you in advance.
j1981Author Commented:
The solution at the link worked for me.

thanks for offering to help.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
j1981Author Commented:
I realized later that this solution woudl work only where the security level of the Infopath form can be set to "Full Trust" which was not so in my network. This was because this solution employs code

Thankfully, I got the name of another webservice I could use in our organization, and got this working.

So this is not a perfect solution, but will work in cases where your forms can have "Full Trust"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.