samba-cvs.cvs
[Top] [All Lists]

svn commit: samba r13657 - branches/SAMBA_3_0/source/include branches/SA

Subject: svn commit: samba r13657 - branches/SAMBA_3_0/source/include branches/SAMBA_3_0/source/libads branches/SAMBA_3_0/source/nsswitch trunk/source/include trunk/source/libads trunk/source/nsswitch
From:
Date: Thu, 23 Feb 2006 14:28:42 +0000 GMT
Author: gd
Date: 2006-02-23 14:28:41 +0000 (Thu, 23 Feb 2006)
New Revision: 13657

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13657

Log:
Let winbindd try to obtain the gecos field from the msSFU30Gecos
attribute when "winbind nss info = sfu" is set. Fixes #3539.

Guenther

Modified:
   branches/SAMBA_3_0/source/include/ads.h
   branches/SAMBA_3_0/source/libads/ads_struct.c
   branches/SAMBA_3_0/source/libads/ldap.c
   branches/SAMBA_3_0/source/nsswitch/winbindd_ads.c
   trunk/source/include/ads.h
   trunk/source/libads/ads_struct.c
   trunk/source/libads/ldap.c
   trunk/source/nsswitch/winbindd_ads.c


Changeset:
Modified: branches/SAMBA_3_0/source/include/ads.h
===================================================================
--- branches/SAMBA_3_0/source/include/ads.h     2006-02-23 13:08:14 UTC (rev 
13656)
+++ branches/SAMBA_3_0/source/include/ads.h     2006-02-23 14:28:41 UTC (rev 
13657)
@@ -48,6 +48,7 @@
                char *sfu_shell_attr;
                char *sfu_uidnumber_attr;
                char *sfu_gidnumber_attr;
+               char *sfu_gecos_attr;
        } schema;
 
 } ADS_STRUCT;
@@ -99,6 +100,7 @@
 #define ADS_ATTR_SFU_GIDNUMBER_OID     "1.2.840.113556.1.6.18.1.311"
 #define ADS_ATTR_SFU_HOMEDIR_OID       "1.2.840.113556.1.6.18.1.344"
 #define ADS_ATTR_SFU_SHELL_OID                 "1.2.840.113556.1.6.18.1.312"
+#define ADS_ATTR_SFU_GECOS_OID                 "1.2.840.113556.1.6.18.1.337"
 
 /* ldap bitwise searches */
 #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803"

Modified: branches/SAMBA_3_0/source/libads/ads_struct.c
===================================================================
--- branches/SAMBA_3_0/source/libads/ads_struct.c       2006-02-23 13:08:14 UTC 
(rev 13656)
+++ branches/SAMBA_3_0/source/libads/ads_struct.c       2006-02-23 14:28:41 UTC 
(rev 13657)
@@ -139,6 +139,7 @@
                SAFE_FREE((*ads)->schema.sfu_gidnumber_attr);
                SAFE_FREE((*ads)->schema.sfu_shell_attr);
                SAFE_FREE((*ads)->schema.sfu_homedir_attr);
+               SAFE_FREE((*ads)->schema.sfu_gecos_attr);
                
                ZERO_STRUCTP(*ads);
 

Modified: branches/SAMBA_3_0/source/libads/ldap.c
===================================================================
--- branches/SAMBA_3_0/source/libads/ldap.c     2006-02-23 13:08:14 UTC (rev 
13656)
+++ branches/SAMBA_3_0/source/libads/ldap.c     2006-02-23 14:28:41 UTC (rev 
13657)
@@ -2628,7 +2628,7 @@
 { 
        BOOL ret = False; 
        TALLOC_CTX *ctx = NULL; 
-       const char *gidnumber, *uidnumber, *homedir, *shell;
+       const char *gidnumber, *uidnumber, *homedir, *shell, *gecos;
 
        ctx = talloc_init("ads_check_sfu_mapping");
        if (ctx == NULL)
@@ -2654,6 +2654,11 @@
                goto done;
        ads->schema.sfu_shell_attr = SMB_STRDUP(shell);
 
+       gecos = ads_get_attrname_by_oid(ads, ctx, ADS_ATTR_SFU_GECOS_OID);
+       if (gecos == NULL)
+               goto done;
+       ads->schema.sfu_gecos_attr = SMB_STRDUP(gecos);
+
        ret = True;
 done:
        if (ctx)

Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_ads.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_ads.c   2006-02-23 13:08:14 UTC 
(rev 13656)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_ads.c   2006-02-23 14:28:41 UTC 
(rev 13657)
@@ -153,7 +153,8 @@
                               "name", "objectSid", "primaryGroupID", 
                               "sAMAccountType", 
                               ADS_ATTR_SFU_HOMEDIR_OID, 
-                              ADS_ATTR_SFU_SHELL_OID, 
+                              ADS_ATTR_SFU_SHELL_OID,
+                              ADS_ATTR_SFU_GECOS_OID,
                               NULL};
        int i, count;
        ADS_STATUS rc;
@@ -193,7 +194,7 @@
        i = 0;
 
        for (msg = ads_first_entry(ads, res); msg; msg = ads_next_entry(ads, 
msg)) {
-               char *name, *gecos;
+               char *name, *gecos = NULL;
                char *homedir = NULL;
                char *shell = NULL;
                uint32 group;
@@ -206,13 +207,19 @@
                }
 
                name = ads_pull_username(ads, mem_ctx, msg);
-               gecos = ads_pull_string(ads, mem_ctx, msg, "name");
+
                if (use_nss_info("sfu")) {
                        homedir = ads_pull_string(ads, mem_ctx, msg, 
                                                  ads->schema.sfu_homedir_attr);
-                       shell = ads_pull_string(ads, mem_ctx, msg, 
-                                               ads->schema.sfu_shell_attr);
+                       shell   = ads_pull_string(ads, mem_ctx, msg, 
+                                                 ads->schema.sfu_shell_attr);
+                       gecos   = ads_pull_string(ads, mem_ctx, msg, 
+                                                 ads->schema.sfu_gecos_attr);
                }
+
+               if (gecos == NULL) {
+                       gecos = ads_pull_string(ads, mem_ctx, msg, "name");
+               }
        
                if (!ads_pull_sid(ads, msg, "objectSid",
                                  &(*info)[i].user_sid)) {
@@ -437,7 +444,8 @@
                               "name", 
                               "primaryGroupID", 
                               ADS_ATTR_SFU_HOMEDIR_OID, 
-                              ADS_ATTR_SFU_SHELL_OID, 
+                              ADS_ATTR_SFU_SHELL_OID,
+                              ADS_ATTR_SFU_GECOS_OID,
                               NULL};
        ADS_STATUS rc;
        int count;
@@ -475,15 +483,20 @@
        }
 
        info->acct_name = ads_pull_username(ads, mem_ctx, msg);
-       info->full_name = ads_pull_string(ads, mem_ctx, msg, "name");
 
        if (use_nss_info("sfu")) {
-               info->homedir = ads_pull_string(ads, mem_ctx, msg, 
-                                               ads->schema.sfu_homedir_attr);
-               info->shell = ads_pull_string(ads, mem_ctx, msg, 
-                                             ads->schema.sfu_shell_attr);
+               info->homedir   = ads_pull_string(ads, mem_ctx, msg, 
+                                                 ads->schema.sfu_homedir_attr);
+               info->shell     = ads_pull_string(ads, mem_ctx, msg, 
+                                                 ads->schema.sfu_shell_attr);
+               info->full_name = ads_pull_string(ads, mem_ctx, msg,
+                                                 ads->schema.sfu_gecos_attr);
        }
 
+       if (info->full_name == NULL) {
+               info->full_name = ads_pull_string(ads, mem_ctx, msg, "name");
+       }
+
        if (!ads_pull_uint32(ads, msg, "primaryGroupID", &group_rid)) {
                DEBUG(1,("No primary group for %s !?\n",
                         sid_string_static(sid)));

Modified: trunk/source/include/ads.h
===================================================================
--- trunk/source/include/ads.h  2006-02-23 13:08:14 UTC (rev 13656)
+++ trunk/source/include/ads.h  2006-02-23 14:28:41 UTC (rev 13657)
@@ -48,6 +48,7 @@
                char *sfu_shell_attr;
                char *sfu_uidnumber_attr;
                char *sfu_gidnumber_attr;
+               char *sfu_gecos_attr;
        } schema;
 
 } ADS_STRUCT;
@@ -99,6 +100,7 @@
 #define ADS_ATTR_SFU_GIDNUMBER_OID     "1.2.840.113556.1.6.18.1.311"
 #define ADS_ATTR_SFU_HOMEDIR_OID       "1.2.840.113556.1.6.18.1.344"
 #define ADS_ATTR_SFU_SHELL_OID                 "1.2.840.113556.1.6.18.1.312"
+#define ADS_ATTR_SFU_GECOS_OID                 "1.2.840.113556.1.6.18.1.337"
 
 /* ldap bitwise searches */
 #define ADS_LDAP_MATCHING_RULE_BIT_AND "1.2.840.113556.1.4.803"

Modified: trunk/source/libads/ads_struct.c
===================================================================
--- trunk/source/libads/ads_struct.c    2006-02-23 13:08:14 UTC (rev 13656)
+++ trunk/source/libads/ads_struct.c    2006-02-23 14:28:41 UTC (rev 13657)
@@ -139,6 +139,7 @@
                SAFE_FREE((*ads)->schema.sfu_gidnumber_attr);
                SAFE_FREE((*ads)->schema.sfu_shell_attr);
                SAFE_FREE((*ads)->schema.sfu_homedir_attr);
+               SAFE_FREE((*ads)->schema.sfu_gecos_attr);
                
                ZERO_STRUCTP(*ads);
 

Modified: trunk/source/libads/ldap.c
===================================================================
--- trunk/source/libads/ldap.c  2006-02-23 13:08:14 UTC (rev 13656)
+++ trunk/source/libads/ldap.c  2006-02-23 14:28:41 UTC (rev 13657)
@@ -2628,7 +2628,7 @@
 { 
        BOOL ret = False; 
        TALLOC_CTX *ctx = NULL; 
-       const char *gidnumber, *uidnumber, *homedir, *shell;
+       const char *gidnumber, *uidnumber, *homedir, *shell, *gecos;
 
        ctx = talloc_init("ads_check_sfu_mapping");
        if (ctx == NULL)
@@ -2654,6 +2654,11 @@
                goto done;
        ads->schema.sfu_shell_attr = SMB_STRDUP(shell);
 
+       gecos = ads_get_attrname_by_oid(ads, ctx, ADS_ATTR_SFU_GECOS_OID);
+       if (gecos == NULL)
+               goto done;
+       ads->schema.sfu_gecos_attr = SMB_STRDUP(gecos);
+
        ret = True;
 done:
        if (ctx)

Modified: trunk/source/nsswitch/winbindd_ads.c
===================================================================
--- trunk/source/nsswitch/winbindd_ads.c        2006-02-23 13:08:14 UTC (rev 
13656)
+++ trunk/source/nsswitch/winbindd_ads.c        2006-02-23 14:28:41 UTC (rev 
13657)
@@ -153,7 +153,8 @@
                               "name", "objectSid", "primaryGroupID", 
                               "sAMAccountType", 
                               ADS_ATTR_SFU_HOMEDIR_OID, 
-                              ADS_ATTR_SFU_SHELL_OID, 
+                              ADS_ATTR_SFU_SHELL_OID,
+                              ADS_ATTR_SFU_GECOS_OID,
                               NULL};
        int i, count;
        ADS_STATUS rc;
@@ -193,7 +194,7 @@
        i = 0;
 
        for (msg = ads_first_entry(ads, res); msg; msg = ads_next_entry(ads, 
msg)) {
-               char *name, *gecos;
+               char *name, *gecos = NULL;
                char *homedir = NULL;
                char *shell = NULL;
                uint32 group;
@@ -206,13 +207,19 @@
                }
 
                name = ads_pull_username(ads, mem_ctx, msg);
-               gecos = ads_pull_string(ads, mem_ctx, msg, "name");
+
                if (use_nss_info("sfu")) {
                        homedir = ads_pull_string(ads, mem_ctx, msg, 
                                                  ads->schema.sfu_homedir_attr);
-                       shell = ads_pull_string(ads, mem_ctx, msg, 
-                                               ads->schema.sfu_shell_attr);
+                       shell   = ads_pull_string(ads, mem_ctx, msg, 
+                                                 ads->schema.sfu_shell_attr);
+                       gecos   = ads_pull_string(ads, mem_ctx, msg, 
+                                                 ads->schema.sfu_gecos_attr);
                }
+
+               if (gecos == NULL) {
+                       gecos = ads_pull_string(ads, mem_ctx, msg, "name");
+               }
        
                if (!ads_pull_sid(ads, msg, "objectSid",
                                  &(*info)[i].user_sid)) {
@@ -437,7 +444,8 @@
                               "name", 
                               "primaryGroupID", 
                               ADS_ATTR_SFU_HOMEDIR_OID, 
-                              ADS_ATTR_SFU_SHELL_OID, 
+                              ADS_ATTR_SFU_SHELL_OID,
+                              ADS_ATTR_SFU_GECOS_OID,
                               NULL};
        ADS_STATUS rc;
        int count;
@@ -475,15 +483,20 @@
        }
 
        info->acct_name = ads_pull_username(ads, mem_ctx, msg);
-       info->full_name = ads_pull_string(ads, mem_ctx, msg, "name");
 
        if (use_nss_info("sfu")) {
-               info->homedir = ads_pull_string(ads, mem_ctx, msg, 
-                                               ads->schema.sfu_homedir_attr);
-               info->shell = ads_pull_string(ads, mem_ctx, msg, 
-                                             ads->schema.sfu_shell_attr);
+               info->homedir   = ads_pull_string(ads, mem_ctx, msg, 
+                                                 ads->schema.sfu_homedir_attr);
+               info->shell     = ads_pull_string(ads, mem_ctx, msg, 
+                                                 ads->schema.sfu_shell_attr);
+               info->full_name = ads_pull_string(ads, mem_ctx, msg,
+                                                 ads->schema.sfu_gecos_attr);
        }
 
+       if (info->full_name == NULL) {
+               info->full_name = ads_pull_string(ads, mem_ctx, msg, "name");
+       }
+
        if (!ads_pull_uint32(ads, msg, "primaryGroupID", &group_rid)) {
                DEBUG(1,("No primary group for %s !?\n",
                         sid_string_static(sid)));

<Prev in Thread] Current Thread [Next in Thread>
  • svn commit: samba r13657 - branches/SAMBA_3_0/source/include branches/SAMBA_3_0/source/libads branches/SAMBA_3_0/source/nsswitch trunk/source/include trunk/source/libads trunk/source/nsswitch, gd <=