AD in Forms Services - InfoPath Dev
in

InfoPath Dev

AD in Forms Services

Last post 11-10-2009 11:46 PM by warrtalon. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-10-2009 11:11 AM

    AD in Forms Services

    I've read enough about using the forms services to use the built in web service to get the current user, etc.  However, I dont want to go that route, nor do I want to call any web service.

    I just want to put the code in the form.  Everytime I do so though, it bombs out.  The code works in Web Apps. I create and even when I debug the code, but once I DEPLOY it, it always throws exceptions when I run it using forms services???  Could it be a security issue?  I am giving the form FULL TRUST so I doubt it.  I could throw the code in a web service, but don't want to.  Code is fine - but it is below.  Anyone have any ideas??

    Thanks, 

     

    private string[] GetRequester()

    {

    DirectoryEntry entry;

    DirectorySearcher myS;

    string[] props = new string[3];

    DirectoryEntry de;

    entry = new DirectoryEntry("....");

    myS = new DirectorySearcher(entry);

    string strUserName = System.Environment.UserName;

    myS.Filter = "(&(ObjectClass=user)(SAMAccountName=" + strUserName + "))";

    SearchResult sc = myS.FindOne();

    de = sc.GetDirectoryEntry();

    //user's display name

    try

    {

    props[0] = de.Properties[
    "displayName"].Value.ToString().ToUpper();

    }

    catch

    {

    props[0] =
    "";

    }

    try

    {

    //extAtt1 = Business Area

    props[1] = de.Properties["extensionAttribute1"].Value.ToString();

    }

    catch

    {

    props[1] =
    "";

    }

    try

    {

    //extAtt2 = Vendor Number

    props[2] = de.Properties["extensionAttribute2"].Value.ToString();

    }

    catch

    {

    props[2] =
    "";

    }

    return props;

    }

         

     

  • 11-10-2009 11:22 AM In reply to

    Do you mind sharing why you prefer to put code directly in the form and use Full Trust (not preferable) as opposed to using a built-in web service that requires no code, no administrative approval, and only domain trust?

  • 11-10-2009 11:41 AM In reply to

    Sure thing and thanks for the reply.  It's because I'll be querying AD a lot and the built in web service wouldn't be able to do some of the things I need to do.  For instance, I need to retrieve the logged on user's manager, and the managers manager, all the way up the hierarchy, for instance, and return all those managers.  A lot of things like this where I don't think I'd be able to do it easily with the built in web service, but the code is already written and tested to put in the form.      

  • 11-10-2009 09:30 PM In reply to

    witzer

    I would say it will be better if you use built in web service. you can also retreive your manager's manager. I think below url can help you. This article is by warrtalon and its amazing. It has helped me, hope the same for you. 

    http://claytoncobb.wordpress.com/2009/06/21/userprofileservice-extended/

     

  • 11-10-2009 11:46 PM In reply to

    Yeah, it's easy to get the manager and the manager's manager, but if you really have some very complicated deep queries you're doing, then maybe you need the code.  Since the folks at Qdabra have their own Active Directory Web Service (again, far better to use a web service than direct code) that they sell and is very effective, I don't think it's likely their devs will help you debug your own version of it.  There's the free, built-in web service that safely touches the user profile database instead of touching AD directly, and then there's the already-built and proven ADWS by Qdabra that is cheap to buy (probably less than the labor put into your code).  I think those are better choices, but at the same time, I apologize for not being able to help with your code - I do all codeless solutions with InfoPath on my end.

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.