From: Volker Lendecke Date: Fri, 21 Apr 2023 14:04:30 +0000 (+0200) Subject: tests: Test ldap whoami exop X-Git-Tag: talloc-2.4.1~873 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8027283dd7c55b611d0af19caccbdd98bb2fa264;p=thirdparty%2Fsamba.git tests: Test ldap whoami exop Signed-off-by: Volker Lendecke Reviewed-by: Andrew Bartlett Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Wed Apr 26 07:20:14 UTC 2023 on atb-devel-224 --- diff --git a/python/samba/tests/ldap_whoami.py b/python/samba/tests/ldap_whoami.py new file mode 100644 index 00000000000..378928e6379 --- /dev/null +++ b/python/samba/tests/ldap_whoami.py @@ -0,0 +1,38 @@ +# Unix SMB/CIFS implementation. +# Copyright (C) Volker Lendecke 2023 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from samba import Ldb,tests +from samba.samba3 import param as s3param +from samba import (credentials,NTSTATUSError) +import os + +class LdapWhoami(tests.TestCase): + def test_ldap_whoami(self): + lp = s3param.get_context() + lp.load(os.getenv("SERVERCONFFILE")); + + domain=os.getenv("DOMAIN") + username=os.getenv("DC_USERNAME") + + creds = credentials.Credentials() + creds.guess(lp) + creds.set_domain(domain) + creds.set_username(username) + creds.set_password(os.getenv("DC_PASSWORD")) + + l=Ldb(f'ldap://{os.getenv("DC_SERVER_IP")}/', credentials=creds, lp=lp) + w=l.whoami() + self.assertEqual(w,f'u:{domain}\\{username}') diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index a0869c3a5de..19764a14397 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -1079,6 +1079,7 @@ planpythontestsuite("ad_dc_default:local", "samba.tests.dcerpc.unix") planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.dcerpc.srvsvc") planpythontestsuite("ad_dc_default:local", "samba.tests.samba_tool.timecmd") planpythontestsuite("ad_dc_default:local", "samba.tests.samba_tool.join") +planpythontestsuite("ad_dc_default:local", "samba.tests.ldap_whoami") planpythontestsuite("ad_member_s3_join", "samba.tests.samba_tool.join_member") planpythontestsuite("ad_dc_default", "samba.tests.samba_tool.join_lmdb_size")