00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <stdio.h>
00010 #include <iostream>
00011
00012 #include <unistd.h>
00013 #include "version.h"
00014
00015 char *ldap_base = NULL;
00016 char *ldap_org = NULL;
00017 char *ldap_class = NULL;
00018
00019 using namespace std;
00020
00021 int main(int argc, char** argv) {
00022 char c;
00023 char *temp;
00024 while ((c = getopt(argc, argv, "b:c:"))!= -1) {
00025 switch (c) {
00026 case 'b':
00027 ldap_base = optarg;
00028 temp = strchr(ldap_base, ',');
00029 if (temp) {
00030 *temp = '\0';
00031 ldap_org = strdup(ldap_base);
00032 *temp = ',';
00033 }
00034 break;
00035 case 'c':
00036 ldap_class = optarg;
00037 break;
00038 default:
00039 break;
00040 }
00041 }
00042
00043 const int LINE_SIZE = 2000;
00044 char line[LINE_SIZE];
00045 while (!cin.eof()) {
00046 cin.getline(line, LINE_SIZE);
00047 int n = strlen(line);
00048 if (!n) continue;
00049 char *f = line + 6;
00050 char *e;
00051 if (*f == '"') {
00052 f++;
00053 e = strchr(f, '"');
00054 }
00055 else {
00056 e = strchr(f, ' ');
00057 }
00058 if (!e) continue;
00059 *e = '\0';
00060 char *m = e+1;
00061 while (*m == ' ') m++;
00062 if (*m != '\0') {
00063 char cn[1000];
00064 snprintf(cn, sizeof(cn), "email %s", f);
00065 printf("dn: cn=%s, %s\n", cn, ldap_base);
00066 printf("cn: %s\n", cn);
00067 printf("sn: %s\n", f);
00068 printf("mail: %s\n", m);
00069 printf("objectClass: %s\n\n", ldap_class);
00070 }
00071 }
00072 }