lib/ldap_escape.c

ソースコードを見る。

関数

char * escape_ldap_string_alloc (const char *s)
 Escape a parameter to an LDAP filter string, so they cannot contain embeded ( ) * or \ chars which may cause it not to parse correctly.
char * escape_rdn_val_string_alloc (const char *s)


関数

char* escape_ldap_string_alloc ( const char *  s  ) 

Escape a parameter to an LDAP filter string, so they cannot contain embeded ( ) * or \ chars which may cause it not to parse correctly.

引数:
s The input string
戻り値:
A string allocated with malloc(), containing the escaped string, and to be free()ed by the caller.

ldap_escape.c36 行で定義されています。

参照先 len.

参照元 add_new_domain_info()ads_find_user_acct()ads_user_info()get_ldap_filter()ldapsam_add_sam_account()ldapsam_create_dom_group()ldapsam_create_user()ldapsam_getgrnam()ldapsam_search_suffix_by_name()ldapsam_set_primary_group()lookup_usergroups_member()smbldap_search_domain_info().

00037 {
00038         size_t len = strlen(s)+1;
00039         char *output = (char *)SMB_MALLOC(len);
00040         const char *sub;
00041         int i = 0;
00042         char *p = output;
00043 
00044         if (output == NULL) {
00045                 return NULL;
00046         }
00047         
00048         while (*s)
00049         {
00050                 switch (*s)
00051                 {
00052                 case '*':
00053                         sub = "\\2a";
00054                         break;
00055                 case '(':
00056                         sub = "\\28";
00057                         break;
00058                 case ')':
00059                         sub = "\\29";
00060                         break;
00061                 case '\\':
00062                         sub = "\\5c";
00063                         break;
00064                 default:
00065                         sub = NULL;
00066                         break;
00067                 }
00068                 
00069                 if (sub) {
00070                         len = len + 3;
00071                         output = (char *)SMB_REALLOC(output, len);
00072                         if (!output) { 
00073                                 return NULL;
00074                         }
00075                         
00076                         p = &output[i];
00077                         strncpy (p, sub, 3);
00078                         p += 3;
00079                         i += 3;
00080 
00081                 } else {
00082                         *p = *s;
00083                         p++;
00084                         i++;
00085                 }
00086                 s++;
00087         }
00088         
00089         *p = '\0';
00090         return output;
00091 }

char* escape_rdn_val_string_alloc ( const char *  s  ) 

ldap_escape.c93 行で定義されています。

参照元 add_new_domain_account_policies()add_new_domain_info()ads_add_group_acct()ads_add_user_acct()ads_create_machine_acct()ldapsam_add_sam_account()ldapsam_create_dom_group()ldapsam_create_user()net_ads_printer_publish()nt_printer_publish_ads().

00094 {
00095         char *output, *p;
00096 
00097         /* The maximum size of the escaped string can be twice the actual size */
00098         output = (char *)SMB_MALLOC(2*strlen(s) + 1);
00099 
00100         if (output == NULL) {
00101                 return NULL;
00102         }
00103 
00104         p = output;
00105         
00106         while (*s)
00107         {
00108                 switch (*s)
00109                 {
00110                 case ',':
00111                 case '=':
00112                 case '+':
00113                 case '<':
00114                 case '>':
00115                 case '#':
00116                 case ';':
00117                 case '\\':
00118                 case '\"':
00119                         *p++ = '\\';
00120                         *p++ = *s;
00121                         break;
00122                 default:
00123                         *p = *s;
00124                         p++;
00125                 }
00126                 
00127                 s++;
00128         }
00129         
00130         *p = '\0';
00131 
00132         /* resize the string to the actual final size */
00133         output = (char *)SMB_REALLOC(output, strlen(output) + 1);
00134         return output;
00135 }


Sambaに対してSat Aug 29 21:23:36 2009に生成されました。  doxygen 1.4.7