>From ea6dc544c875de69e26b5a4bd582a0a322dcdb95 Mon Sep 17 00:00:00 2001
From: Lukasz Zalewski <lukas@eecs.qmul.ac.uk>
Date: Sat, 16 Oct 2010 19:51:09 +0100
Subject: [PATCH] [Bug 7736] Addition of userPrincipalName attribute when new account is created

---
 source4/scripting/python/samba/samdb.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index a40d10d..60dc2fe 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -274,10 +274,12 @@ member: %s
 
         user_dn = "CN=%s,%s,%s" % (cn, (userou or "CN=Users"), self.domain_dn())
 
+        user_principal_name = "%s@%s" % (username, self.domain_dn().replace("DC=", "").replace(",", "."))
         # The new user record. Note the reliance on the SAMLDB module which
         # fills in the default informations
         ldbmessage = {"dn": user_dn,
                       "sAMAccountName": username,
+                      "userPrincipalName": user_principal_name,
                       "objectClass": "user"}
 
         if surname is not None:
-- 
1.5.5.6


