From da0f3bd2291e561fd8b6f0fafd4bf6cb52dad722 Mon Sep 17 00:00:00 2001
From: Kamen Mazdrashki <kamenim@samba.org>
Date: Fri, 1 Oct 2010 03:29:33 +0300
Subject: s4-getopt.py: Make Anonymous creds when no credentials

are supplied on command line and caller doesn't want us
to guess credentials from environment
---
 source4/scripting/python/samba/getopt.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py
index 62c94e4411..08fe692ce0 100644
--- a/source4/scripting/python/samba/getopt.py
+++ b/source4/scripting/python/samba/getopt.py
@@ -196,13 +196,18 @@ class CredentialsOptionsDouble(CredentialsOptions):
     def _set_simple_bind_dn2(self, option, opt_str, arg, parser):
         self.creds2.set_bind_dn(arg)
 
-    def get_credentials2(self, lp):
+    def get_credentials2(self, lp, guess=True):
         """Obtain the credentials set on the command-line.
 
         :param lp: Loadparm object to use.
+        :param guess: Try guess Credentials from environment
         :return: Credentials object
         """
-        self.creds2.guess(lp)
+        if guess:
+            self.creds2.guess(lp)
+        elif not self.creds2.get_username():
+                self.creds2.set_anonymous()
+
         if self.no_pass2:
             self.creds2.set_cmdline_callbacks()
         return self.creds2
-- 
cgit