Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Web-based LDAP User Accounts System

by mpeg4codec (Pilgrim)
on Dec 09, 2008 at 17:26 UTC ( #729215=note: print w/ replies, xml ) Need Help??


in reply to Re: Web-based LDAP User Accounts System
in thread Web-based LDAP User Accounts System

I wholheartedly second this motion. Created one myself with Net::LDAP and GTK2/Glade, and I found it about as useful as writing custom forum software. Yeah, you get to control every tiny niggling detail of the implementation, but there's probably something out there that satisfies 98% of your needs (and the other 2% can be worked around).

The one major benefit of the roll-your-own school of thought is that you can simplify for non-techie end users (as inochi implies). That was one of the goals of my system, and it worked well to that end. Not sure how many of the open source solutions cater to this crowd.


Comment on Re^2: Web-based LDAP User Accounts System
Re^3: Web-based LDAP User Accounts System
by SteveS832001 (Sexton) on Dec 09, 2008 at 20:56 UTC
    I know you wanted a Web Version, but here is something you might find Educational. I tried creating a Web Version, but I haven't had time to do it. But atleast I can give you something to look at. It only unlocks people that are locked out.
    but it is always nice to see how someone else has done it.
    use Win32::OLE; use Win32::OLE 'in'; use Win32::OLE::Enum; use Win32::NetAdmin; @empty = (); ($sec,$min,$hour,$day,$mon,$yr,$wday,$yday,$dntcare)=localtime(time); + $yr-=100; $yr="$yr"; $yr = (length($yr)<2) ? "0$yr" : $yr; $mon = (++$mon < 10) ? "0$mon" : "$mon"; $day = ($day < 10) ? "0$day" : "$day"; $date = "unlock$day-$mon-$yr.txt"; open (UNLOCK , ">>$date") || die "Can\\'t Create file"; while ( $choice != 7 ) { system(cls); print "=============================================================== +===========\n"; print "This Program Will Unlock Users on the Network. Enter the \n"; print "Number for the location and press the Enter Key\n"; print "Created by: Steve Sherman\n"; print "=============================================================== +===========\n"; print "\n"; print "\n"; print "1) Main\n"; print "2) Regional\n"; print "3) Cuba\n"; print "4) Union\n"; print "5) Motor\n"; print "6) Labadie\n"; print "7) Exit\n\n"; $choice = <stdin>; chomp($choice); sub Localuser { if (Win32::NetAdmin::LoggedOnUsers($server,\%userRef)) { print UNLOCK "User: " . $userRef{1} . " Unlocked the Following user\n" +; @local = split(/;/,$userRef{1}); my $accesslocal = Win32::OLE->GetObject("LDAP://$local[0]"); foreach $group (in $accesslocal->{memberof}) { push(@groups, $group); print "$group\n"; } } } sub Lookup { my $adsuser = Win32::OLE->GetObject("LDAP://bos-ad01/ou=$location,dc=a +sdf,dc=com") || die ("Can't find user: ".Win32::OLE->LastError()."\n"); $strDomain = "adsg"; $num = 1; foreach $strUsername (in $adsuser){ my $objUser = Win32::OLE->GetObject("WinNT://$strDomai +n/$strUsername-> {sAMAccountName}"); if ($objUser->{IsAccountLocked} == 1) { #$objUser->{IsAccountLocked} = 0; #$objUser->SetInfo; print "$num) $strUsername->{sAMAccountName}\n"; push(@users, $strUsername->{sAMAccountName}); push(@DnUsers, $strUsername->{distinguishedName} +); $num++; } }#end foreach if (@users == @empty) { print "No Users to Unlock \n\n"; } } sub unlock { if (@users == @empty) { next; } if ($choice == 0) { next; } $choice = $choice - 1; my $objUser = Win32::OLE->GetObject("LDAP://bos-ad01/$DnUsers[$cho +ice]"); print "$!\n"; $objUser->{IsAccountLocked} = 0; $objUser->SetInfo(); Localuser(); print UNLOCK "$users[$choice]\n"; print UNLOCK "$day-$mon-$yr\n\n"; @users = (); @DnUsers = (); } if ($choice == 1) { $location = "main"; system(cls); print "======================================================= +===================\n"; print "Select The Number that is associated with the user you +wish to unlock\n"; print "then press the Enter key.\n"; print "************************ WARNING WARNING WARNING ****** +*******************\n"; print "Please Only Unlock The user(s) that have requested to b +e unlocked\n"; print "======================================================= +===================\n"; Lookup(); print "0 ) Exit\n\n"; $choice = <stdin>; unlock(); } if ($choice == 2) { $location = "Regional"; system(cls); print "Select The User you wish to Unlock\n"; print "To Exit Press 0\n"; print "=====================================\n\n\n"; Lookup(); print "0 ) Exit\n\n"; $choice = <stdin>; unlock(); } if ($choice == 3) { $location = "Cuba"; system(cls); print "Select The User you wish to Unlock\n"; print "To Exit Press 0\n"; print "=====================================\n\n\n"; Lookup(); print "0 ) Exit\n\n"; $choice = <stdin>; if ($choice > 0) { unlock(); } } if ($choice == 4) { $location = "Union"; system(cls); print "Select The User you wish to Unlock\n"; print "To Exit Press 0\n"; print "=====================================\n\n\n"; Lookup(); print "0 ) Exit\n\n"; $choice = <stdin>; if ($choice > 0) { unlock(); } } if ($choice == 5) { $location = "Main"; system(cls); print "Select The User you wish to Unlock\n"; print "To Exit Press 0\n"; print "=====================================\n\n\n"; Lookup(); print "0 ) Exit\n\n"; $choice = <stdin>; if ($choice > 0) { unlock(); } } if ($choice == 6) { $location = "Labadie"; system(cls); print "Select The User you wish to Unlock\n"; print "To Exit Press 0\n"; print "=====================================\n\n\n"; Lookup(); print "0 ) Exit\n\n"; $choice = <stdin>; if ($choice > 0) { unlock(); } } }

      Just a general comment (nothing to do with the original question): unless you're being paid by 'lines of code'... ;) I'd suggest you factor out the common code (the parts wrapped within "if ($choice == X) {...}") into a subroutine, which you then call with the uncommon part(s) - such as $location - as parameter(s). (You might even simply pass $choice, and do the mapping to location within the routine (using a hash or array), in which case you would no longer need the if-chain.)

      This would not only make the code shorter, but also - and more importantly - easier to maintain. Just suppose you needed to modify the "if ($choice > 0) { unlock(); }" fragment for whatever reason, you'd only have to do it once, and not all over the place...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://729215]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-07-26 20:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (179 votes), past polls