SunQuest
           LDAP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesLDAP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 9 votes, 5.00 average. Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #106  
Old June 8th, 2005, 05:18 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,686 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 16 h 27 m 51 sec
Reputation Power: 259
Not really shure but I think this can help

On the site you mentioned I found another line (beside the OpenSSL configuration), which reads:
Quote:
Configure OpenLDAP:

Add the following to your ldap.conf file.
(found as /usr/local/openldap/etc/openldap/ldap.conf)

#--begin--

# Instruct client to NOT request a server's cert.
TLS_REQCERT never

# Define location of CA Cert
TLS_CACERT /usr/local/ssl/certs/AD_CA_CERT.pem
TLS_CACERTDIR /usr/local/ssl/certs

#--end--

Note that ldap.conf is a config file used also by LDAP CLIENT, this is important, slapd.conf is used by LDAP SERVER.
Probably ease of creating and finding all those files is why you are advised to install the whole openldap server.

Last edited by pabloj : June 8th, 2005 at 05:22 AM.

Reply With Quote
  #107  
Old June 8th, 2005, 07:51 AM
giorg giorg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 7 giorg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by pabloj
Not really shure but I think this can help

On the site you mentioned I found another line (beside the OpenSSL configuration), which reads:
Note that ldap.conf is a config file used also by LDAP CLIENT, this is important, slapd.conf is used by LDAP SERVER.
Probably ease of creating and finding all those files is why you are advised to install the whole openldap server.

Yes I've read this and of course I did modify the configuration; the error I mentioned before came after I modified and restarted the daemon.

Reply With Quote
  #108  
Old June 8th, 2005, 08:04 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,686 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 16 h 27 m 51 sec
Reputation Power: 259
Ok, googleing around I got into openssl verify ....

20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate
the issuer certificate of a locally looked up certificate could not be found. This normally means the list of trusted certificates is not complete

You might need to add the issuer certificate.
Hope this helps

Reply With Quote
  #109  
Old June 8th, 2005, 08:27 AM
giorg giorg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 7 giorg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 40 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by pabloj
You might need to add the issuer certificate.

Yes I've also googlied around and found that, and my point at this time is exactly that I don't know how to do it...
thx a lot for your help

Reply With Quote
  #110  
Old June 13th, 2005, 02:49 PM
sjferwerda sjferwerda is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 1 sjferwerda User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 44 sec
Reputation Power: 0
Any success with PHP5?

I've tried all of the very helpful suggestions and code in this thread, but cannot modify a password. I still get the "Unwilling to perform..." error message. Has anyone been able to modify AD passwords, running PHP5 on Windows and IIS? Also, when I run ldp.exe I can see that there is a LDAPS connection to AD by checking netstat, but when I run my PHP script I never see a LDAPS connection. I only ever get a LDAP connection. I'm thinking that PHP is not establishing a secure connection to AD. Is there any way to verify that PHP is establishing a secure LDAPS connection other than checking netstat? Thanks!

Reply With Quote
  #111  
Old June 13th, 2005, 04:47 PM
MatthewClark's Avatar
MatthewClark MatthewClark is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: San Angelo, Texas (USA)
Posts: 286 MatthewClark User rank is Corporal (100 - 500 Reputation Level)MatthewClark User rank is Corporal (100 - 500 Reputation Level)MatthewClark User rank is Corporal (100 - 500 Reputation Level)MatthewClark User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 48 m 16 sec
Reputation Power: 7
Send a message via ICQ to MatthewClark Send a message via AIM to MatthewClark Send a message via Yahoo to MatthewClark
Well, without looking very far into this, the problem you describe is very similar, if not identical, to the problems mentioned in this thread that pertained to PHP4.

I know it's a long thread, but there are some posts that may solve this problem (something to do with SSL and certificates and DC registry hacks).
__________________
InLesserTerms.net
Sometimes it takes a little cussin' to get things done right.

Reply With Quote
  #112  
Old July 27th, 2005, 07:01 PM
Mayday Mayday is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 5 Mayday User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 sec
Reputation Power: 0
VMWare for testing

I am testing this solution and I use vmware to do it. Costs a little cash but owns for testing out anything.

Reply With Quote
  #113  
Old August 2nd, 2005, 10:16 AM
Dominic32 Dominic32 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 1 Dominic32 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 38 sec
Reputation Power: 0
ssl certs

I have done a bit of work on this:

have a look at http://apple-scripts.com/forums/

i have just written a PDF guide to get the openSSL working..

it is geared for OSX and unix but you should be able to fit it to IIS etc.

Reply With Quote
  #114  
Old September 15th, 2005, 02:26 PM
brett.howard brett.howard is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 2 brett.howard User rank is Private First Class (20 - 50 Reputation Level)brett.howard User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 19 m 37 sec
Reputation Power: 0
Great thread, helped me a lot with getting the TLS/SSL sorted then ran into the same problem as a lot of others, formatting the PW.

It seems that Server 2003 requires a UTF-16 string with no byte order marks and revesed byte order as the password. As my php was not complied with mb_string I had no unicode support. As my passwords were all straight ASCII strings I wrote this cheap dirty code to get it working. This code also produces base 64 encoded strings that match the output from stringconverter.exe but only if the supplied string is pure ASCII

Hope it helps

Code:
<?php

$newpass="enter32";
echo $newpass . " is " . strlen($newpass) . " long  - ";
$unipass="\"\x00";
$i=0;
while ($i < strlen($newpass)):
$unipass = $unipass . $newpass{$i} . "\x00";
$i++;
endwhile;
$unipass= $unipass . "\"\x00";
echo "Unicode password is " . $unipass . " and is " . strlen($unipass) . " long
- " ;
$encpass = base64_encode($unipass);
echo "Base-64 encoded string is " . $encpass;
?>

For those interested I was connecting from a FreeBSD 5.4 box to a AD on a Server 2003 using a certificate from the 2003 box imported into the default openssl/openldap install on the FreeBSD box. I can connect from the ldap command line tools and have successfully modified the unicodepwd field on the Active Directory.

Cheers,
Brett

Reply With Quote
  #115  
Old September 16th, 2005, 11:24 AM
brett.howard brett.howard is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 2 brett.howard User rank is Private First Class (20 - 50 Reputation Level)brett.howard User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 19 m 37 sec
Reputation Power: 0
I can confirm I can modify the 'unicodePwd' attribute from php5. I think a lot of people are not getting a secure ldap connection to the server even though they think they are.

The ldapconnect() take either a URL or a hostname and port number so connecting via ldapconnect("ldap://yourdoain.com", 636) does not work, this connects unsecured to port 389 and ignores the specified port and you wont be able to update the 'unicodePwd' attribute.

To get a TLS/SSL ldap conection you need to connect via either:

ldapconnect("yourdomain.com","636") or
ldapconnect("ldaps://yourdomain.com)

if these conect methods return the error cannot connect to ldap server your SLL/TLS is not setup correctly. You simply cannot get a SSL/TLS connection if you specify ladp:// in the connect field instead of ldaps://

I can connect from a machine that is not part of the domain via php, openssl and openldap. The key is all in getting the certificate from the AD and importing into openssl, then configuring openldap to use the certificate and finally and just as important making sure the webserver/php module is set to use the cert. I can give specific instructions on how to do this for apache/openssl/openldap on linux or BSD but not for IIS/php setups but the principal is the same.

Hope this helps.

Brett
Comments on this post
Viper_SB agrees: thanks very informative

Reply With Quote
  #116  
Old October 13th, 2005, 12:34 PM
pteeter pteeter is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 2 pteeter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 9 sec
Reputation Power: 0
encoding, ssl, etc.

Amazing that this thread has continued for so long. It seems to be the most informative place for info about PHP driven password changes for AD users.

I'm super close, thanks to everyone who has contributed to this thread. A few points of clarification.

1. Most recently, brett.howard says he can do the password replacement with PHP*5*. Is php5 a must? Can php4 be used - say 4.3.10?

2. brett's post also mentions a distinction about encoding the password for Win2003 server. Does UTF-16 need to be used? If php has mbstring configured - any syntax hints on using it instead of the 'dirty' method with base64 encoding he suggested?

3. from the start, matthew clark suggested that using port 636 or 3269 without indicating LDAPS was the preferred method of connecting over SSL. do brett's recent comments contradict this? I cannot connect if I use a hostname of ldaps://<hostname>/ and a port of 636 or 3269. It has to do with configuring openssl and the cert on the webserver side I suspect. Hopfully dominic32's documentation will help...I'm running my php on a Mac with Apache.

Your follow up would be appreciated.
Is anyone actively monitoring this thread anymore?

Reply With Quote
  #117  
Old October 20th, 2005, 07:01 PM
pteeter pteeter is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 2 pteeter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 31 m 9 sec
Reputation Power: 0
form now working

With Dominic from apple-scripts assistance, I finally got my PHP form working.

Some of the highlights I found interesting and challenging.

1. PHP, utilizing the openldap libraries, needs to bind to AD over port 636 or via LDAPS. To accomplish this an x509 certificate issued by a CA either on the AD server or from the same domain (correct me if I'm wrong) needs to be installed and configured for use on the Apache/PHP server.

2. When binding to AD to perform the ldap_mod_replace on the user entry of interest, the bind DN must be a domain administrator and can actually use the form of <samaccountname>@DOMAIN.

3. Finally, I did not find it necessary to base64 encode the converted password string. The code I used to properly format the string is as follows:

### assume $new_passwd is passed in via $POST['passwd var']

$new_passwd = "\"".$new_passwd."\"";
for ($i = 0; $i < (strlen($new_passwd)); $i++) {
$uni_passwd .= "{$new_passwd{$i}}\000";
};
$userdata["unicodePwd"] = $uni_passwd;

Reply With Quote
  #118  
Old March 12th, 2006, 09:48 PM
matrism matrism is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 10 matrism User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 6 m 5 sec
Reputation Power: 0
hello..

Im trying to figure out and helping a fren on this thing..
I am able to connect to the AD server do comparison and all.. but when im try to change the password on AD, my interface shows an error msg " constraint violation". any ideas? help?

Reply With Quote
  #119  
Old April 3rd, 2006, 09:33 AM
chadsmith729's Avatar
chadsmith729 chadsmith729 is offline
--Retired--
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Sep 2003
Location: Enjoying forum retirement.
Posts: 3,113 chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)chadsmith729 User rank is Lieutenant General (80000 - 90000 Reputation Level)  Folding Points: 283454 Folding Title: Super Ultimate Folder - Level 1Folding Points: 283454 Folding Title: Super Ultimate Folder - Level 1Folding Points: 283454 Folding Title: Super Ultimate Folder - Level 1Folding Points: 283454 Folding Title: Super Ultimate Folder - Level 1Folding Points: 283454 Folding Title: Super Ultimate Folder - Level 1Folding Points: 283454 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 16 h 31 m 40 sec
Reputation Power: 893
Hey just thought I would throw this out to everyone.

It is two articles that I wrote using PHP and AD together. It includes all source, screenshots, articles (PDF). Check it out.
Get the zipped file here

Good luck everyone,
Chad
Comments on this post
pabloj agrees: Thanks
__________________
Get A Supplier LLC | Hilarious Comic

--- Pretty much retired from the forum. I will get back on every now and then, and maybe answer a few questions.

Reply With Quote