+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
Web Development Thread, How to lookup the logged in user on website in Coding and Web Development; Thanks for all the help dude...
  1. #16

    MK-2's Avatar
    Join Date
    Oct 2006
    Location
    Nottingham
    Posts
    3,237
    Thank Post
    149
    Thanked 581 Times in 307 Posts
    Blog Entries
    8
    Rep Power
    200
    Thanks for all the help dude

  2. #17

    vikpaw's Avatar
    Join Date
    Sep 2006
    Location
    Saudi Arabia
    Posts
    6,008
    Thank Post
    680
    Thanked 1,397 Times in 1,157 Posts
    Rep Power
    353
    Quote Originally Posted by localzuk View Post
    Right, function versions of it

    Code:
     //Returns a bound LDAP connection
    function getldapconnection($host,$user,$password){ 
    $ad = ldap_connect("ldap://" . $host,389) or die('Could not connect to LDAP server.');
    ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
    ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
    @ldap_bind($ad, $user, $password) or die('Could not bind to AD.');
    return $ad;
    }
     
    //Checks group membership for a user
    function checkldapgroupmembership($ldap,$basedn,$group,$username){
    $filter = "(sAMAccountName=" . $username . ")";
    $attr = array("memberof");
    $result = ldap_search($ldap, $basedn, $filter, $attr) or exit("Unable to search LDAP server");
    $entries = ldap_get_entries($ldap,$result);
    $access = 0;
    foreach($entries[0]['memberof'] as $grps){
    if(strpos($grps,$group)){ $access = 1; break;}
    }
    return $access;
    }
    Then you'd just call it like so:

    $ld = getldapconnection("server","cn=Administrator,cn=Us ers,dc=domain,dc=local","password");

    $result = checlldapgroupmemberships($ld,"dc=domain,dc=local","Group Name","user.name");

    With result either being 0 or 1.
    tony, can i just edit typo in the 2nd function call and then suggest splitting this part of thread over to coding or web or something....?
    Last edited by vikpaw; 23rd March 2011 at 09:33 AM. Reason: highlight

  3. #18

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,816
    Thank Post
    517
    Thanked 2,473 Times in 1,916 Posts
    Blog Entries
    24
    Rep Power
    836
    Quote Originally Posted by vikpaw View Post
    tony, can i just edit typo in the 2nd function call and then suggest splitting this part of thread over to coding or web or something....?
    Sure. I'd suggest splitting back to where MK-2 asked about how to do group checking.

  4. #19

    vikpaw's Avatar
    Join Date
    Sep 2006
    Location
    Saudi Arabia
    Posts
    6,008
    Thank Post
    680
    Thanked 1,397 Times in 1,157 Posts
    Rep Power
    353
    Quote Originally Posted by localzuk View Post
    Sure. I'd suggest splitting back to where MK-2 asked about how to do group checking.
    Moved so hopefully it's all there and makes sense. Let me know if i've missed something or thread title is not apt.

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. RDP times out after 30 seconds when no user logged on
    By OverWorked in forum Thin Client and Virtual Machines
    Replies: 6
    Last Post: 15th May 2013, 03:11 PM
  2. Prevent showing last user logged in on 7
    By ranj in forum Windows 7
    Replies: 2
    Last Post: 18th August 2010, 01:46 PM
  3. user logged in
    By firefighting in forum Scripts
    Replies: 1
    Last Post: 12th February 2009, 10:14 AM
  4. automatic VNC to PC a user is logged onto
    By ChrisP in forum How do you do....it?
    Replies: 2
    Last Post: 7th December 2007, 04:23 PM
  5. Replies: 5
    Last Post: 21st February 2007, 04:40 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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