<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[iRedMail — Use of sn attribute in iredmail/iredadmin LDAP]]></title>
	<link rel="self" href="http://www.iredmail.org/forum/feed-atom-topic4438.xml" />
	<updated>2013-02-07T20:07:24Z</updated>
	<generator>PunBB</generator>
	<id>http://www.iredmail.org/forum/topic4438-use-of-sn-attribute-in-iredmailiredadmin-ldap.html</id>
		<entry>
			<title type="html"><![CDATA[Re: Use of sn attribute in iredmail/iredadmin LDAP]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20242.html#p20242" />
			<content type="html"><![CDATA[<p>Thx ZhangHuangbin</p><p>Works perfectly</p><p>have fun.</p>]]></content>
			<author>
				<name><![CDATA[buzzzo]]></name>
				<uri>http://www.iredmail.org/forum/user19835.html</uri>
			</author>
			<updated>2013-02-07T20:07:24Z</updated>
			<id>http://www.iredmail.org/forum/post20242.html#p20242</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use of sn attribute in iredmail/iredadmin LDAP]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20231.html#p20231" />
			<content type="html"><![CDATA[<p>Oops, my mistake, i forgot another patch. So sorry about this.</p><p>Again, backup files which will be patched before applying this patch.<br /></p><div class="codebox"><pre><code>diff -r dc949701c440 -r 094b12353beb libs/ldaplib/admin.py
--- a/libs/ldaplib/admin.py    Sat Jan 05 15:39:52 2013 +0800
+++ b/libs/ldaplib/admin.py    Sun Jan 06 17:34:11 2013 +0800
@@ -103,6 +103,7 @@
     def update(self, profile_type, mail, data):
         self.profile_type = web.safestr(profile_type)
         self.mail = web.safestr(mail)
+        self.username, self.domain = self.mail.split(&#039;@&#039;, 1)
 
         if session.get(&#039;domainGlobalAdmin&#039;) is not True and session.get(&#039;username&#039;) != self.mail:
             # Don&#039;t allow to view/update other admins&#039; profile.
@@ -118,7 +119,19 @@
 
             # Get cn.
             cn = data.get(&#039;cn&#039;, None)
-            mod_attrs += ldaputils.getSingleModAttr(attr=&#039;cn&#039;, value=cn, default=self.mail.split(&#039;@&#039;)[0],)
+            mod_attrs += ldaputils.getSingleModAttr(attr=&#039;cn&#039;,
+                                                    value=cn,
+                                                    default=self.username)
+
+            first_name = data.get(&#039;first_name&#039;, &#039;&#039;)
+            mod_attrs += ldaputils.getSingleModAttr(attr=&#039;givenName&#039;,
+                                                    value=first_name,
+                                                    default=self.username)
+
+            last_name = data.get(&#039;last_name&#039;, &#039;&#039;)
+            mod_attrs += ldaputils.getSingleModAttr(attr=&#039;sn&#039;,
+                                                    value=last_name,
+                                                    default=self.username)
 
             # Get accountStatus.
             if &#039;accountStatus&#039; in data.keys():
diff -r dc949701c440 -r 094b12353beb libs/ldaplib/user.py
--- a/libs/ldaplib/user.py    Sat Jan 05 15:39:52 2013 +0800
+++ b/libs/ldaplib/user.py    Sun Jan 06 17:34:11 2013 +0800
@@ -435,7 +435,7 @@
     def update(self, profile_type, mail, data):
         self.profile_type = web.safestr(profile_type)
         self.mail = str(mail).lower()
-        self.domain = self.mail.split(&#039;@&#039;, 1)[-1]
+        self.username, self.domain = self.mail.split(&#039;@&#039;, 1)
 
         domainAccountSetting = {}
 
@@ -480,7 +480,19 @@
 
             # Get display name.
             cn = data.get(&#039;cn&#039;, None)
-            mod_attrs += ldaputils.getSingleModAttr(attr=&#039;cn&#039;, value=cn, default=self.mail.split(&#039;@&#039;)[0])
+            mod_attrs += ldaputils.getSingleModAttr(attr=&#039;cn&#039;,
+                                                    value=cn,
+                                                    default=self.username)
+
+            first_name = data.get(&#039;first_name&#039;, &#039;&#039;)
+            mod_attrs += ldaputils.getSingleModAttr(attr=&#039;givenName&#039;,
+                                                    value=first_name,
+                                                    default=self.username)
+
+            last_name = data.get(&#039;last_name&#039;, &#039;&#039;)
+            mod_attrs += ldaputils.getSingleModAttr(attr=&#039;sn&#039;,
+                                                    value=last_name,
+                                                    default=self.username)
 
             # Get preferred language: short lang code. e.g. en_US, de_DE.
             preferred_lang = web.safestr(data.get(&#039;preferredLanguage&#039;, &#039;en_US&#039;))
diff -r dc949701c440 -r 094b12353beb templates/default/macros/general.html
--- a/templates/default/macros/general.html    Sat Jan 05 15:39:52 2013 +0800
+++ b/templates/default/macros/general.html    Sun Jan 06 17:34:11 2013 +0800
@@ -644,7 +644,7 @@
     &lt;div class=&quot;form-field clear&quot;&gt;
         &lt;h4 class=&quot;size-250 fl-space&quot;&gt;&amp;nbsp;&lt;/h4&gt;
         &lt;span class=&quot;clean-padding bt-space20&quot;&gt;
-            &lt;input type=&quot;text&quot; name=&quot;first_name&quot; value=&quot;{{ first_name |e }}&quot; size=&quot;15&quot; class=&quot;text&quot; title=&quot;{{ _(&#039;First name&#039;) }}&quot; /&gt;
+            &lt;input type=&quot;text&quot; name=&quot;first_name&quot; value=&quot;{{ first_name |e }}&quot; size=&quot;14&quot; class=&quot;text&quot; title=&quot;{{ _(&#039;First name&#039;) }}&quot; /&gt;
             &lt;input type=&quot;text&quot; name=&quot;last_name&quot; value=&quot;{{ last_name |e }}&quot; size=&quot;15&quot; class=&quot;text&quot; title=&quot;{{ _(&#039;Last name&#039;) }}&quot;/&gt;
         &lt;/span&gt;
     &lt;/div&gt;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-02-07T12:25:22Z</updated>
			<id>http://www.iredmail.org/forum/post20231.html#p20231</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use of sn attribute in iredmail/iredadmin LDAP]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20223.html#p20223" />
			<content type="html"><![CDATA[<p>Ive patched and receive some hunks, but seems to be applied successfully.<br />The gui shows the &quot;first name&quot; and &quot;last name&quot; fields, but when i save nothing happens: the modification are not applied to the ldap entry.</p><p>thx</p>]]></content>
			<author>
				<name><![CDATA[buzzzo]]></name>
				<uri>http://www.iredmail.org/forum/user19835.html</uri>
			</author>
			<updated>2013-02-06T18:23:44Z</updated>
			<id>http://www.iredmail.org/forum/post20223.html#p20223</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use of sn attribute in iredmail/iredadmin LDAP]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20212.html#p20212" />
			<content type="html"><![CDATA[<p>In one month (iRedMail, iRedAPD, iRedAdmin-Pro). Below is patch for iRedAdmin-Pro-LDAP-1.8.1 if you want to give it a try. WARNING: Please backup files which are going to be patched before applying patch.<br /></p><div class="codebox"><pre><code>diff -r 68511236e5d3 -r dc949701c440 libs/ldaplib/attrs.py
--- a/libs/ldaplib/attrs.py    Fri Jan 04 22:30:15 2013 +0800
+++ b/libs/ldaplib/attrs.py    Sat Jan 05 15:39:52 2013 +0800
@@ -49,7 +49,7 @@
                       &#039;domainGlobalAdmin&#039;, &#039;enabledService&#039;,
                       &#039;objectClass&#039;,
                      ]
-ADMIN_ATTRS_ALL = ADMIN_SEARCH_ATTRS
+ADMIN_ATTRS_ALL = ADMIN_SEARCH_ATTRS + [&#039;sn&#039;, &#039;givenName&#039;]
 
 # ---------------------------------------------------------
 # Domain related.
@@ -114,6 +114,7 @@
 ]
 
 USER_ATTRS_ALL = USER_SEARCH_ATTRS + [
+    &#039;sn&#039;, &#039;givenName&#039;,
     &#039;mobile&#039;, &#039;telephoneNumber&#039;, &#039;preferredLanguage&#039;, &#039;memberOfGroup&#039;,
     &#039;userRecipientBccAddress&#039;, &#039;userSenderBccAddress&#039;,
     &#039;mailForwardingAddress&#039;, &#039;mtaTransport&#039;,
diff -r 68511236e5d3 -r dc949701c440 templates/default/ldap/admin/profile.html
--- a/templates/default/ldap/admin/profile.html    Fri Jan 04 22:30:15 2013 +0800
+++ b/templates/default/ldap/admin/profile.html    Sat Jan 05 15:39:52 2013 +0800
@@ -25,8 +25,11 @@
 
 {% set entry = profile[0][1] %}
 {% set cn = entry.get(&#039;cn&#039;, [&#039;&#039;])[0].decode(&#039;utf-8&#039;) %}
+{% set first_name = entry.get(&#039;givenName&#039;, [&#039;&#039;])[0].decode(&#039;utf-8&#039;) |e %}
+{% set last_name = entry.get(&#039;sn&#039;, [&#039;&#039;])[0].decode(&#039;utf-8&#039;) |e %}
 {% set accountStatus = entry.get(&#039;accountStatus&#039;, [&#039;disabled&#039;])[0] %}
 
+
 {% block breadcrumb %}
     {% set crumbs = [
             (ctx.homepath + &#039;/admins&#039;, _(&#039;All admins&#039;),),
@@ -66,7 +69,11 @@
                                     &lt;div class=&quot;bt-space0&quot;&gt;&amp;nbsp;&lt;/div&gt;
                                 {% endif %}
 
-                                {{ display_input_cn(cn=cn, accountType=&#039;admin&#039;) }}
+                                {{ display_input_cn(cn,
+                                                    tooltip=_(&#039;Full name&#039;),
+                                                    show_first_last_name=true,
+                                                    first_name=first_name,
+                                                    last_name=last_name) }}
                                 {{ display_preferred_language(value=entry.get(&#039;preferredLanguage&#039;, [&#039;en_US&#039;])[0], languagemaps=languagemaps) }}
                             &lt;/div&gt;
 
diff -r 68511236e5d3 -r dc949701c440 templates/default/ldap/user/profile.html
--- a/templates/default/ldap/user/profile.html    Fri Jan 04 22:30:15 2013 +0800
+++ b/templates/default/ldap/user/profile.html    Sat Jan 05 15:39:52 2013 +0800
@@ -60,13 +60,14 @@
 {% endif %}
 
 {% if profile_type == &#039;general&#039; %}
+    {% set first_name = entries.get(&#039;givenName&#039;, [&#039;&#039;])[0].decode(&#039;utf-8&#039;) |e %}
+    {% set last_name = entries.get(&#039;sn&#039;, [&#039;&#039;])[0].decode(&#039;utf-8&#039;) |e %}
     {% set jobtitle = entries.get(&#039;title&#039;, [&#039;&#039;])[0].decode(&#039;utf-8&#039;) |e %}
     {% set mobile = entries.get(&#039;mobile&#039;, [&#039;&#039;])[0] |e %}
     {% set telephoneNumber = entries.get(&#039;telephoneNumber&#039;, []) %}
     {% set mailQuota = &#039;%d&#039; % (entries.get(&#039;mailQuota&#039;, [0])[0] |int /1024/1024) %}
     {% set usedQuota = accountUsedQuota.get(mail, {}).get(&#039;bytes&#039;, 0) %}
 
-    {#-- Member of Groups --#}
     {% set memberOfGroup = entries.get(&#039;memberOfGroup&#039;, []) %}
 
 {% elif profile_type == &#039;forwarding&#039; %}
@@ -155,7 +156,11 @@
                 {{ display_in_global_address_book(enabledService=enabledService) }}
 
                 &lt;div class=&quot;bt-space10&quot;&gt;&lt;/div&gt;
-                {{ display_input_cn(cn) }}
+                {{ display_input_cn(cn,
+                                    tooltip=_(&#039;Full name&#039;),
+                                    show_first_last_name=true,
+                                    first_name=first_name,
+                                    last_name=last_name) }}
                 {{ display_preferred_language(value=entries.get(&#039;preferredLanguage&#039;, [&#039;en_US&#039;])[0], languagemaps=languagemaps) }}
                 {{ display_quota(value=mailQuota, show_value_in_input=true, used_quota=usedQuota, show_used_quota=true) }}
 
diff -r 68511236e5d3 -r dc949701c440 templates/default/macros/general.html
--- a/templates/default/macros/general.html    Fri Jan 04 22:30:15 2013 +0800
+++ b/templates/default/macros/general.html    Sat Jan 05 15:39:52 2013 +0800
@@ -81,7 +81,7 @@
         });
 
         {# tooltip #}
-        $(&quot;a[title], img[title], span[title]&quot;).tooltip({
+        $(&quot;a[title], img[title], span[title], input[title]&quot;).tooltip({
             position: &quot;top center&quot;,
             offset: [-5, 0],
             predelay: 300,
@@ -90,14 +90,6 @@
             opacity: 1
         });
 
-        $(&quot;input[title]&quot;).tooltip({
-            position: &quot;center right&quot;,
-            offset: [-2, 10],
-            delay: 100,
-            effect: &quot;fade&quot;,
-            opacity: 1
-        });
-
         {% if &#039;tablesorter&#039; in plugins %}
             $(&quot;.tablesorter&quot;).tablesorter(
                 {% if nonSortedCols |length &gt; 0 %}
@@ -631,7 +623,7 @@
 {%- endmacro %}
 
 
-{% macro display_input_cn(cn=&#039;&#039;, name=&#039;cn&#039;, accountType=&#039;user&#039;, tooltip=&#039;&#039;, size=&quot;size-250&quot;) -%}
+{% macro display_input_cn(cn=&#039;&#039;, name=&#039;cn&#039;, accountType=&#039;user&#039;, tooltip=&#039;&#039;, size=&quot;size-250&quot;, show_first_last_name=false, first_name=&#039;&#039;, last_name=&#039;&#039;) -%}
     {% if cn is sameas none %}
         {% set cn = &#039;&#039; %}
     {% endif %}
@@ -647,6 +639,16 @@
             &lt;input type=&quot;text&quot; name=&quot;{{ name |e }}&quot; value=&quot;{{ cn |e }}&quot; size=&quot;35&quot; class=&quot;text&quot; {% if tooltip != &#039;&#039; %}title=&quot;{{ tooltip |e }}&quot;{% endif %} /&gt;
         &lt;/span&gt;
     &lt;/div&gt;
+
+    {% if show_first_last_name is sameas true %}
+    &lt;div class=&quot;form-field clear&quot;&gt;
+        &lt;h4 class=&quot;size-250 fl-space&quot;&gt;&amp;nbsp;&lt;/h4&gt;
+        &lt;span class=&quot;clean-padding bt-space20&quot;&gt;
+            &lt;input type=&quot;text&quot; name=&quot;first_name&quot; value=&quot;{{ first_name |e }}&quot; size=&quot;15&quot; class=&quot;text&quot; title=&quot;{{ _(&#039;First name&#039;) }}&quot; /&gt;
+            &lt;input type=&quot;text&quot; name=&quot;last_name&quot; value=&quot;{{ last_name |e }}&quot; size=&quot;15&quot; class=&quot;text&quot; title=&quot;{{ _(&#039;Last name&#039;) }}&quot;/&gt;
+        &lt;/span&gt;
+    &lt;/div&gt;
+    {% endif %}
 {%- endmacro %}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-02-06T14:12:44Z</updated>
			<id>http://www.iredmail.org/forum/post20212.html#p20212</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use of sn attribute in iredmail/iredadmin LDAP]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20197.html#p20197" />
			<content type="html"><![CDATA[<p>Very cool.</p><p>Have you planned a release date ?</p><p>thx</p>]]></content>
			<author>
				<name><![CDATA[buzzzo]]></name>
				<uri>http://www.iredmail.org/forum/user19835.html</uri>
			</author>
			<updated>2013-02-05T18:17:45Z</updated>
			<id>http://www.iredmail.org/forum/post20197.html#p20197</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use of sn attribute in iredmail/iredadmin LDAP]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20168.html#p20168" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>buzzzo wrote:</cite><blockquote><p>1) is it possibile to set the &quot;sn&quot; attribute to the &quot;cn&quot; (tipically: First Name Last Name)<br />2) is there a reason to set the &quot;sn&quot; to the uid ? is this required for some internal iredmail&#039;s component ?<br />3) why not updating uid field instead of &quot;employenumber&quot; via the iredadmin gui ?</p></blockquote></div><p>Upcoming release will let admin to manage First Name (givenName), Last Name (sn), Display Name (cn), User/Employee ID (employeenumber). Screenshot:</p><p><span class="postimg"><img src="http://iredmail.org/images/iredadmin/user_profile_general.png" alt="http://iredmail.org/images/iredadmin/user_profile_general.png" /></span></p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-02-04T15:07:32Z</updated>
			<id>http://www.iredmail.org/forum/post20168.html#p20168</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Use of sn attribute in iredmail/iredadmin LDAP]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post20162.html#p20162" />
			<content type="html"><![CDATA[<p>Hi</p><p>I&#039;ve seen when creating a user thet on the ldif entry the attribute &quot;sn&quot; takes the uid field.<br />So if the user&#039;s mail is foo@bar.com then:</p><p>the uid attribute is: foo<br />the sn attribute&nbsp; is: foo</p><p>Additionaly the web gui (iredadmin pro) show a field &quot;uid&quot; which does not translates in modifying the &quot;uid&quot; attribute, but the employenumber.</p><p>So the questions are:</p><p>1) is it possibile to set the &quot;sn&quot; attribute to the &quot;cn&quot; (tipically: First Name Last Name)<br />2) is there a reason to set the &quot;sn&quot; to the uid ? is this required for some internal iredmail&#039;s component ?<br />3) why not updating uid field instead of &quot;employenumber&quot; via the iredadmin gui ?</p><p>Thx for help in advance</p>]]></content>
			<author>
				<name><![CDATA[buzzzo]]></name>
				<uri>http://www.iredmail.org/forum/user19835.html</uri>
			</author>
			<updated>2013-02-04T10:54:00Z</updated>
			<id>http://www.iredmail.org/forum/post20162.html#p20162</id>
		</entry>
</feed>
