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.

How do I do an AD lookup to populate InfoPath fields?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt B - 11 Aug 2006 15:25 GMT
How do I do an AD lookup to populate InfoPath fields?

I am trying to populate the username field.

Thanks
S.Y.M. Wong-A-Ton - 13 Aug 2006 02:39 GMT
It depends on what language you're using. You can use DirectoryServices in
managed code or ADSI in script to do a lookup. Search this newsgroup on
"Active Directory" to find some samples.
---
S.Y.M. Wong-A-Ton

> How do I do an AD lookup to populate InfoPath fields?
>
> I am trying to populate the username field.
>
> Thanks
hurtlingturtle - 14 Aug 2006 12:41 GMT
Hi Matt,
Real easy, use either Application.User.UserName in code or the
userName() function within the set field value action dialog.
hope this helps
cheers
Bruce

> How do I do an AD lookup to populate InfoPath fields?
>
> I am trying to populate the username field.
>
> Thanks
hurtlingturtle - 14 Aug 2006 12:44 GMT
code example.....
           // set current user properties
           string networkIdPath =
"/ns1:Invoice/ns1:Control/ns1:UserTrail/ns1:CurrentUser/ns1:NetworkId";
           XPathNavigator networkId =
this.MainDataSource.CreateNavigator().SelectSingleNode(networkIdPath,
this.NamespaceManager);

           networkId.SetValue(Application.User.UserName);

> Hi Matt,
> Real easy, use either Application.User.UserName in code or the
[quoted text clipped - 8 lines]
> >
> > Thanks
CW - 15 Aug 2006 01:52 GMT
Sorry to sound like such a newbie, but where exactly would one place
this code?

Thanks for the input.

> code example.....
>             // set current user properties
[quoted text clipped - 18 lines]
> > >
> > > Thanks
hurtlingturtle - 15 Aug 2006 11:41 GMT
Hi Carl,
Yes, it is for Infopath 2007.  Is that what you are using? (otherwise I
suggest googling for  2003 answers as it's not quite so easy from what
I hear)
If you are using 2007 then you can place this code in the most
appropriate event eg: form loading or button click etc....  Use VSTA
from within Infopath.
hope this helps
cheers
Bruce

> Sorry to sound like such a newbie, but where exactly would one place
> this code?
[quoted text clipped - 23 lines]
> > > >
> > > > Thanks
CW - 15 Aug 2006 17:40 GMT
Hi HurtlingTurtle, no, I/we use Infopath 2003.  I'm pretty well versed
with Access VBA and have some pretty slick code working there but once
I started working in Infopath, I must confess I've fallen back on the
old GUI way to do things. The forms I'm working with are for the most
part based on samples which are based on jscript. In Access VBA, I got
well versed with VBA so VB, VB script and VB in .Net are easy to read
but reading anything like JS, or C# to me is illegible. Maybe it's some
form of "Code Aphasia" eh? I know if you have a background in C++ it's
easier but my background is cchemistry and picked up the VB along the
way.

Anyway, I've been searching for a way to add the AD/network username
(e.g: carlw) to a field on a form. The GUI design view doesn't seem to
offer one (why it's not included as a function is beyond me) and I've
seen a bunch of other people posting methods  but like I said in my
previous post, where do you put them. I've tried a few such as
environment.user etc. but to no avail. The posting you offered as an
example looks promising but would you add that to OnLoad and add it as
is?

Thanks for the patience. We all start at the beginning right. :)

CW

> Hi Carl,
> Yes, it is for Infopath 2007.  Is that what you are using? (otherwise I
[quoted text clipped - 34 lines]
> > > > >
> > > > > Thanks
hurtlingturtle - 15 Aug 2006 17:52 GMT
Hi Carl,
Sorry about that, I haven't used Infopath 2003 at all.  Only started
using InfoPath 2007 recently for a customer.
I know it can be done as like you say there is lots of example code out
there.  I would've thought it should be fairly straight forward as to
where to put the code, there should be some sort of code editor in IP
2003 for doing just that, perhaps some kind person out there that uses
2003 can point you in the right direction.
cheers
Bruce
ps: just done a quick google and found the following article
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebsrv/html/h
ttpsecurity.asp

this may help or may actually scare you away completely ;-)

> Hi HurtlingTurtle, no, I/we use Infopath 2003.  I'm pretty well versed
> with Access VBA and have some pretty slick code working there but once
[quoted text clipped - 58 lines]
> > > > > >
> > > > > > Thanks
CW - 16 Aug 2006 14:16 GMT
Actually it's very interesting, thanks for the feedback. Much
appreciated. I'll keep that one bookmarked.

CW

> Hi Carl,
> Sorry about that, I haven't used Infopath 2003 at all.  Only started
[quoted text clipped - 72 lines]
> > > > > > >
> > > > > > > Thanks
CW - 15 Aug 2006 01:50 GMT
That's for Infopath 2007 isn't it?

> Hi Matt,
> Real easy, use either Application.User.UserName in code or the
[quoted text clipped - 8 lines]
> >
> > Thanks
 
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.