summaryrefslogtreecommitdiff
path: root/source3/libads/ldap.c
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-06-17 16:20:29 +0200
committerGünther Deschner <gd@samba.org>2008-06-17 19:54:09 +0200
commit0447e6a0a7f1b16f986f0fe5304cd65ee691277c (patch)
tree76bac74981eb3967686a152f87e8f3c1f3885d6e /source3/libads/ldap.c
parentfd288b4110a988ef37f153dfee95381f6675a7ef (diff)
downloadsamba-0447e6a0a7f1b16f986f0fe5304cd65ee691277c.tar.gz
samba-0447e6a0a7f1b16f986f0fe5304cd65ee691277c.tar.bz2
samba-0447e6a0a7f1b16f986f0fe5304cd65ee691277c.zip
libads: add ads_get_machine_kvno() to make ads_get_kvno() a bit more generic.
Guenther (This used to be commit cb7ace209c2051ae02647188715fa6ee324c2bf6)
Diffstat (limited to 'source3/libads/ldap.c')
-rw-r--r--source3/libads/ldap.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 01c4b442c8..7b9e51068b 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -1516,13 +1516,13 @@ ADS_STATUS ads_add_strlist(TALLOC_CTX *ctx, ADS_MODLIST *mods,
}
/**
- * Determines the computer account's current KVNO via an LDAP lookup
+ * Determines the an account's current KVNO via an LDAP lookup
* @param ads An initialized ADS_STRUCT
- * @param machine_name the NetBIOS name of the computer, which is used to identify the computer account.
- * @return the kvno for the computer account, or -1 in case of a failure.
+ * @param account_name the NT samaccountname.
+ * @return the kvno for the account, or -1 in case of a failure.
**/
-uint32 ads_get_kvno(ADS_STRUCT *ads, const char *machine_name)
+uint32 ads_get_kvno(ADS_STRUCT *ads, const char *account_name)
{
LDAPMessage *res = NULL;
uint32 kvno = (uint32)-1; /* -1 indicates a failure */
@@ -1531,14 +1531,14 @@ uint32 ads_get_kvno(ADS_STRUCT *ads, const char *machine_name)
char *dn_string = NULL;
ADS_STATUS ret = ADS_ERROR(LDAP_SUCCESS);
- DEBUG(5,("ads_get_kvno: Searching for host %s\n", machine_name));
- if (asprintf(&filter, "(samAccountName=%s$)", machine_name) == -1) {
+ DEBUG(5,("ads_get_kvno: Searching for account %s\n", account_name));
+ if (asprintf(&filter, "(samAccountName=%s)", account_name) == -1) {
return kvno;
}
ret = ads_search(ads, &res, filter, attrs);
SAFE_FREE(filter);
if (!ADS_ERR_OK(ret) || (ads_count_replies(ads, res) != 1)) {
- DEBUG(1,("ads_get_kvno: Computer Account For %s not found.\n", machine_name));
+ DEBUG(1,("ads_get_kvno: Account for %s not found.\n", account_name));
ads_msgfree(ads, res);
return kvno;
}
@@ -1574,6 +1574,28 @@ uint32 ads_get_kvno(ADS_STRUCT *ads, const char *machine_name)
}
/**
+ * Determines the computer account's current KVNO via an LDAP lookup
+ * @param ads An initialized ADS_STRUCT
+ * @param machine_name the NetBIOS name of the computer, which is used to identify the computer account.
+ * @return the kvno for the computer account, or -1 in case of a failure.
+ **/
+
+uint32_t ads_get_machine_kvno(ADS_STRUCT *ads, const char *machine_name)
+{
+ char *computer_account = NULL;
+ uint32_t kvno = -1;
+
+ if (asprintf(&computer_account, "%s$", machine_name) < 0) {
+ return kvno;
+ }
+
+ kvno = ads_get_kvno(ads, computer_account);
+ free(computer_account);
+
+ return kvno;
+}
+
+/**
* This clears out all registered spn's for a given hostname
* @param ads An initilaized ADS_STRUCT
* @param machine_name the NetBIOS name of the computer.