8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.135 2006/03/06 17:41:43 momjian Exp $
11
+ * $PostgreSQL: pgsql/src/backend/libpq/auth.c,v 1.136 2006/03/16 18:11:17 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -712,6 +712,7 @@ CheckPAMAuth(Port *port, char *user, char *password)
712
712
713
713
714
714
#ifdef USE_LDAP
715
+
715
716
static int
716
717
CheckLDAPAuth (Port * port )
717
718
{
@@ -774,7 +775,8 @@ CheckLDAPAuth(Port *port)
774
775
if (r < 2 )
775
776
{
776
777
ereport (LOG ,
777
- (errmsg ("Invalid LDAP url: '%s'" , port -> auth_arg )));
778
+ (errmsg ("invalid LDAP URL: \"%s\"" ,
779
+ port -> auth_arg )));
778
780
return STATUS_ERROR ;
779
781
}
780
782
@@ -783,26 +785,26 @@ CheckLDAPAuth(Port *port)
783
785
passwd = recv_password_packet (port );
784
786
if (passwd == NULL )
785
787
return STATUS_EOF ; /* client wouldn't send password */
786
-
787
788
788
789
ldap = ldap_init (server , ldapport );
789
790
if (!ldap )
790
791
{
791
- ereport (LOG ,
792
- (errmsg ("Failed to initialize LDAP: %i" ,
793
792
#ifndef WIN32
794
- errno
793
+ ereport (LOG ,
794
+ (errmsg ("could not initialize LDAP: error %d" ,
795
+ errno )));
795
796
#else
796
- (int )LdapGetLastError ()
797
+ ereport (LOG ,
798
+ (errmsg ("could not initialize LDAP: error %d" ,
799
+ (int ) LdapGetLastError ())));
797
800
#endif
798
- )));
799
801
return STATUS_ERROR ;
800
802
}
801
803
802
804
if ((r = ldap_set_option (ldap , LDAP_OPT_PROTOCOL_VERSION , & ldapversion )) != LDAP_SUCCESS )
803
805
{
804
806
ereport (LOG ,
805
- (errmsg ("Failed to set LDAP version: %i " , r )));
807
+ (errmsg ("could not set LDAP protocol version: error %d " , r )));
806
808
return STATUS_ERROR ;
807
809
}
808
810
@@ -815,12 +817,13 @@ CheckLDAPAuth(Port *port)
815
817
#endif
816
818
{
817
819
ereport (LOG ,
818
- (errmsg ("Failed to start LDAP TLS session: %i " , r )));
820
+ (errmsg ("could not start LDAP TLS session: error %d " , r )));
819
821
return STATUS_ERROR ;
820
822
}
821
823
}
822
824
823
- snprintf (fulluser , sizeof (fulluser )- 1 , "%s%s%s" , prefix , port -> user_name , suffix );
825
+ snprintf (fulluser , sizeof (fulluser )- 1 , "%s%s%s" ,
826
+ prefix , port -> user_name , suffix );
824
827
fulluser [sizeof (fulluser )- 1 ] = '\0' ;
825
828
826
829
r = ldap_simple_bind_s (ldap , fulluser , passwd );
@@ -829,12 +832,14 @@ CheckLDAPAuth(Port *port)
829
832
if (r != LDAP_SUCCESS )
830
833
{
831
834
ereport (LOG ,
832
- (errmsg ("LDAP login failed for user '%s' on server '%s': %i" ,fulluser ,server ,r )));
835
+ (errmsg ("LDAP login failed for user \"%s\" on server \"%s\": error %d" ,
836
+ fulluser , server , r )));
833
837
return STATUS_ERROR ;
834
838
}
835
839
836
840
return STATUS_OK ;
837
841
}
842
+
838
843
#endif /* USE_LDAP */
839
844
840
845
/*
0 commit comments