retrieve LDAP info within webservice

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default retrieve LDAP info within webservice

    Hi,

    Using wse2.0 a user logs on to my application. The webservice runs
    within the domain, the user does not (not allways). So I use the
    websrvice to read from the central database and to veryfy the
    username/pasword. Doing that I want to return the full name for the
    user.

    To do this I wrote (well, partially find it on the internet ;-)) this
    method:

    public static String GetLDAPName(String userAccount)
    {
    DirectoryEntry entry = new DirectoryEntry("LDAP://xxx");
    String account =userAccount.Replace(@"@xxx", "");
    try
    {
    DirectorySearcher search = new DirectorySearcher(entry);
    search.Filter = "(SAMAccountName=" + account + ")";
    search.PropertiesToLoad.Add("displayName");
    SearchResult result = search.FindOne();

    if( result != null )
    {
    return result.Properties["displayname"][0].ToString();
    }
    else
    {
    return "Unknown User";
    }
    }
    catch( Exception ex )
    {
    return ex.Message;
    }
    }

    If I try it, it allways returns "an operations error occured". That's
    good info isn't it!! NOT!

    To find out if the method is wrong I also put it in a windows app and
    testied it on another machine (no visual studio installed, just x-copy
    deployed) in the same domein as the webserver. Without having to set any
    trusts it ran fine!

    What's wrong here? Is this a matter of setting permissions on the
    webserver? And what would that be?


    MAzzel,


    Roland
    --
    ---
    Roland Wolters
    [url]http://www.habbiebabbie.net[/url]
    ***** Please react via UseNet only ********


    --
    ---
    Roland Wolters
    [url]http://www.habbiebabbie.net[/url]
    ***** Please react via UseNet only ********
    Roland Wolters Guest

  2. Similar Questions and Discussions

    1. Module to retrieve general TTF font info
      I'm attempting to find a module that will allow me to retrieve general information regarding a TrueType font. Typeface Name File Size Version...
    2. Query IIS or LDAP for User Info
      Is it possible to query from IIS or LDAP, the user who is currently accessing the web server? I'm trying to set up a secure site that uses...
    3. #17908 [Fbk->NoF]: Can't retrieve info using OCIColumnIsNULL()
      ID: 17908 Updated by: sniper@php.net Reported By: ThorpeJ at gao dot gov -Status: Feedback +Status: ...
    4. #17908 [Asn->Fbk]: Can't retrieve info using OCIColumnIsNULL()
      ID: 17908 Updated by: sniper@php.net Reported By: ThorpeJ at gao dot gov -Status: Assigned +Status: ...
    5. WeUpdate cannot retrieve info
      I like to download the latest updates to Win XP to save on my computer in case I ever need to reinstall it. However, when I downloaded several...
  3. #2

    Default Re: retrieve LDAP info within webservice

    Hello Roland,

    Need to make sure that the account ASP.net runs under has been set up
    as a user in LDAP
    HTH
    Regards,
    Dilip Krishnan
    MCAD, MCSD.net
    dkrishnan at geniant dot com
    [url]http://www.geniant.com[/url]
    > Hi,
    >
    > Using wse2.0 a user logs on to my application. The webservice runs
    > within the domain, the user does not (not allways). So I use the
    > websrvice to read from the central database and to veryfy the
    > username/pasword. Doing that I want to return the full name for the
    > user.
    >
    > To do this I wrote (well, partially find it on the internet ;-)) this
    > method:
    >
    > public static String GetLDAPName(String userAccount)
    > {
    > DirectoryEntry entry = new DirectoryEntry("LDAP://xxx");
    > String account =userAccount.Replace(@"@xxx", "");
    > try
    > {
    > DirectorySearcher search = new DirectorySearcher(entry);
    > search.Filter = "(SAMAccountName=" + account + ")";
    > search.PropertiesToLoad.Add("displayName");
    > SearchResult result = search.FindOne();
    > if( result != null )
    > {
    > return result.Properties["displayname"][0].ToString();
    > }
    > else
    > {
    > return "Unknown User";
    > }
    > }
    > catch( Exception ex )
    > {
    > return ex.Message;
    > }
    > }
    > If I try it, it allways returns "an operations error occured". That's
    > good info isn't it!! NOT!
    >
    > To find out if the method is wrong I also put it in a windows app and
    > testied it on another machine (no visual studio installed, just x-copy
    > deployed) in the same domein as the webserver. Without having to set
    > any trusts it ran fine!
    >
    > What's wrong here? Is this a matter of setting permissions on the
    > webserver? And what would that be?
    >
    > MAzzel,
    >
    > Roland
    >

    Dilip Krishnan Guest

  4. #3

    Default Re: retrieve LDAP info within webservice

    Dilip Krishnan <dkrishnan@NOSPAM.geniant.com> wrote in
    news:127809632409810325414784@msnews.microsoft.com :

    Hi,

    The user running the webservice has not been set as a user in LDAP. The
    admin is not going to change this.

    Is there a way around this? I do have a valid authenticated
    usernametoken. Can I use this to read the full name for that user? Maybe
    use impersonation via this username token? how?


    Roland

    > Hello Roland,
    >
    > Need to make sure that the account ASP.net runs under has been set
    up
    > as a user in LDAP
    > HTH
    > Regards,
    > Dilip Krishnan
    > MCAD, MCSD.net
    > dkrishnan at geniant dot com
    > [url]http://www.geniant.com[/url]
    >
    >> Hi,
    >>
    >> Using wse2.0 a user logs on to my application. The webservice runs
    >> within the domain, the user does not (not allways). So I use the
    >> websrvice to read from the central database and to veryfy the
    >> username/pasword. Doing that I want to return the full name for the
    >> user.
    >>
    >> To do this I wrote (well, partially find it on the internet ;-)) this
    >> method:
    >>
    >> public static String GetLDAPName(String userAccount)
    >> {
    >> DirectoryEntry entry = new DirectoryEntry("LDAP://xxx");
    >> String account =userAccount.Replace(@"@xxx", "");
    >> try
    >> {
    >> DirectorySearcher search = new DirectorySearcher(entry);
    >> search.Filter = "(SAMAccountName=" + account + ")";
    >> search.PropertiesToLoad.Add("displayName");
    >> SearchResult result = search.FindOne();
    >> if( result != null )
    >> {
    >> return result.Properties["displayname"][0].ToString();
    >> }
    >> else
    >> {
    >> return "Unknown User";
    >> }
    >> }
    >> catch( Exception ex )
    >> {
    >> return ex.Message;
    >> }
    >> }
    >> If I try it, it allways returns "an operations error occured". That's
    >> good info isn't it!! NOT!
    >>
    >> To find out if the method is wrong I also put it in a windows app and
    >> testied it on another machine (no visual studio installed, just x-
    copy
    >> deployed) in the same domein as the webserver. Without having to set
    >> any trusts it ran fine!
    >>
    >> What's wrong here? Is this a matter of setting permissions on the
    >> webserver? And what would that be?
    >>
    >> MAzzel,
    >>
    >> Roland
    >>
    >
    >
    >


    --
    ---
    Roland Wolters
    [url]http://www.habbiebabbie.net[/url]
    ***** Please react via UseNet only ********
    Roland Wolters Guest

  5. #4

    Default Re: retrieve LDAP info within webservice

    Hello Roland

    Maybe you're better off asking in the aspnet.security group. I know there
    have been a lot discussion of the "multi-hop" issue, especially then
    retrieving information from AD.

    Not much help, but give it a try.

    Regards
    Henrik
    [url]http://websolver.blogspot.com[/url]


    "Roland Wolters" <Roland@wolters-ict.nl> skrev i en meddelelse
    news:Xns95DB6A9A1AFDEwoltersictnl@207.46.248.16...
    > Dilip Krishnan <dkrishnan@NOSPAM.geniant.com> wrote in
    > news:127809632409810325414784@msnews.microsoft.com :
    >
    > Hi,
    >
    > The user running the webservice has not been set as a user in LDAP. The
    > admin is not going to change this.
    >
    > Is there a way around this? I do have a valid authenticated
    > usernametoken. Can I use this to read the full name for that user? Maybe
    > use impersonation via this username token? how?
    >
    >
    > Roland
    >
    >
    > > Hello Roland,
    > >
    > > Need to make sure that the account ASP.net runs under has been set
    > up
    > > as a user in LDAP
    > > HTH
    > > Regards,
    > > Dilip Krishnan
    > > MCAD, MCSD.net
    > > dkrishnan at geniant dot com
    > > [url]http://www.geniant.com[/url]
    > >
    > >> Hi,
    > >>
    > >> Using wse2.0 a user logs on to my application. The webservice runs
    > >> within the domain, the user does not (not allways). So I use the
    > >> websrvice to read from the central database and to veryfy the
    > >> username/pasword. Doing that I want to return the full name for the
    > >> user.
    > >>
    > >> To do this I wrote (well, partially find it on the internet ;-)) this
    > >> method:
    > >>
    > >> public static String GetLDAPName(String userAccount)
    > >> {
    > >> DirectoryEntry entry = new DirectoryEntry("LDAP://xxx");
    > >> String account =userAccount.Replace(@"@xxx", "");
    > >> try
    > >> {
    > >> DirectorySearcher search = new DirectorySearcher(entry);
    > >> search.Filter = "(SAMAccountName=" + account + ")";
    > >> search.PropertiesToLoad.Add("displayName");
    > >> SearchResult result = search.FindOne();
    > >> if( result != null )
    > >> {
    > >> return result.Properties["displayname"][0].ToString();
    > >> }
    > >> else
    > >> {
    > >> return "Unknown User";
    > >> }
    > >> }
    > >> catch( Exception ex )
    > >> {
    > >> return ex.Message;
    > >> }
    > >> }
    > >> If I try it, it allways returns "an operations error occured". That's
    > >> good info isn't it!! NOT!
    > >>
    > >> To find out if the method is wrong I also put it in a windows app and
    > >> testied it on another machine (no visual studio installed, just x-
    > copy
    > >> deployed) in the same domein as the webserver. Without having to set
    > >> any trusts it ran fine!
    > >>
    > >> What's wrong here? Is this a matter of setting permissions on the
    > >> webserver? And what would that be?
    > >>
    > >> MAzzel,
    > >>
    > >> Roland
    > >>
    > >
    > >
    > >
    >
    >
    >
    > --
    > ---
    > Roland Wolters
    > [url]http://www.habbiebabbie.net[/url]
    > ***** Please react via UseNet only ********

    HG Guest

  6. #5

    Default Re: retrieve LDAP info within webservice

    Hello Roland,
    > Dilip Krishnan <dkrishnan@NOSPAM.geniant.com> wrote in
    > news:127809632409810325414784@msnews.microsoft.com :
    >
    > Hi,
    >
    > The user running the webservice has not been set as a user in LDAP.
    > The admin is not going to change this.
    >
    > Is there a way around this? I do have a valid authenticated
    > usernametoken. Can I use this to read the full name for that user?
    > Maybe use impersonation via this username token? how?
    >
    Yes you could setup the username token to authenticate against windows domain
    (no custom username token manager). You will probably have to jump a few
    hoops to get that user to impersonate as the web service identity however.
    This is because of the subtle difference in transport based security and
    soap based security, which we will not go into here. The easiest way to go
    about this is use a surrogate user that is provisioned in LDAP and use that
    account to connect always. That way you dont have to provision users for
    each web server you have.
    > Roland
    >
    HTH
    Regards,
    Dilip Krishnan
    MCAD, MCSD.net
    dkrishnan at geniant dot com
    [url]http://www.geniant.com[/url]



    Dilip Krishnan Guest

  7. #6

    Default Re: retrieve LDAP info within webservice

    I'm having this exact same problem. Roland have you found a solution to it?
    Basically I can get info from when not using a trust connection (SSL). But
    when I try to enable trust connection it just doesn't work. Tracing through
    the code I can tell that it does "connect" to the ldap server but when it
    tries to bind a user/pass to it, it gives an exception.

    Another thing I noticed is that if I DON'T use it as a webservice and use it
    as a class driver, everything works fine and dandy.

    Does anyone have any solution? About the user impersonating as a webservice
    "solution" above. Can you tell me what I have to do step by step?

    Thanks

    "Dilip Krishnan" wrote:
    > Hello Roland,
    >
    > > Dilip Krishnan <dkrishnan@NOSPAM.geniant.com> wrote in
    > > news:127809632409810325414784@msnews.microsoft.com :
    > >
    > > Hi,
    > >
    > > The user running the webservice has not been set as a user in LDAP.
    > > The admin is not going to change this.
    > >
    > > Is there a way around this? I do have a valid authenticated
    > > usernametoken. Can I use this to read the full name for that user?
    > > Maybe use impersonation via this username token? how?
    > >
    >
    > Yes you could setup the username token to authenticate against windows domain
    > (no custom username token manager). You will probably have to jump a few
    > hoops to get that user to impersonate as the web service identity however.
    > This is because of the subtle difference in transport based security and
    > soap based security, which we will not go into here. The easiest way to go
    > about this is use a surrogate user that is provisioned in LDAP and use that
    > account to connect always. That way you dont have to provision users for
    > each web server you have.
    >
    > > Roland
    > >
    > HTH
    > Regards,
    > Dilip Krishnan
    > MCAD, MCSD.net
    > dkrishnan at geniant dot com
    > [url]http://www.geniant.com[/url]
    >
    >
    >
    >
    Shaun Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139