]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:libads: add ads_connect_creds() helper
authorStefan Metzmacher <metze@samba.org>
Wed, 27 Apr 2022 11:11:26 +0000 (13:11 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 14 May 2024 10:18:31 +0000 (10:18 +0000)
In future ads_connect_creds() will be used by callers directly instead
of using ads_connect().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libads/ads_proto.h
source3/libads/ldap.c

index c44119eebdfc1a1b36f988ce8b42e03fe99483a8..1256652c5e0856b40ad81d6dbe6a3061d75ac8af 100644 (file)
@@ -87,6 +87,7 @@ int ads_kinit_password(ADS_STRUCT *ads);
 bool ads_sitename_match(ADS_STRUCT *ads);
 bool ads_closest_dc(ADS_STRUCT *ads);
 ADS_STATUS ads_connect_cldap_only(ADS_STRUCT *ads);
+ADS_STATUS ads_connect_creds(ADS_STRUCT *ads, struct cli_credentials *creds);
 ADS_STATUS ads_connect(ADS_STRUCT *ads);
 ADS_STATUS ads_connect_user_creds(ADS_STRUCT *ads);
 void ads_zero_ldap(ADS_STRUCT *ads);
index 593881c8d4f3e0510066087dd3b1ad12b05b9f6f..1e05d14e4aa97117b7d2894ac826696d18ed5bc2 100644 (file)
@@ -1122,6 +1122,34 @@ ADS_STATUS ads_connect_cldap_only(ADS_STRUCT *ads)
        return ads_connect_internal(ads, NULL);
 }
 
+/**
+ * Connect to the LDAP server
+ * @param ads Pointer to an existing ADS_STRUCT
+ * @return status of connection
+ **/
+ADS_STATUS ads_connect_creds(ADS_STRUCT *ads, struct cli_credentials *creds)
+{
+       SMB_ASSERT(creds != NULL);
+
+       /*
+        * We allow upgrades from
+        * ADS_AUTH_NO_BIND if credentials
+        * are specified
+        */
+       ads->auth.flags &= ~ADS_AUTH_NO_BIND;
+
+       /*
+        * We allow upgrades from ADS_AUTH_ANON_BIND,
+        * as we don't want to use simple binds with
+        * non-anon credentials
+        */
+       if (!cli_credentials_is_anonymous(creds)) {
+               ads->auth.flags &= ~ADS_AUTH_ANON_BIND;
+       }
+
+       return ads_connect_internal(ads, creds);
+}
+
 /*
  * Connect to the LDAP server
  * @param ads Pointer to an existing ADS_STRUCT