+static gchar *extract_name(const char *uid)
+{
+ if (uid == NULL)
+ return NULL;
+ if (!strncmp(uid, "CN=", 3)) {
+ gchar *result = g_strdup(uid+3);
+ if (strstr(result, ","))
+ *(strstr(result, ",")) = '\0';
+ return result;
+ } else if (strstr(uid, ",CN=")) {
+ gchar *result = g_strdup(strstr(uid, ",CN=")+4);
+ if (strstr(result, ","))
+ *(strstr(result, ",")) = '\0';
+ return result;
+ } else {
+ return g_strdup(uid);
+ }
+}