@@ -565,6 +565,29 @@ class LDAPConnection : public ObjectWrap
565565 return scope.Close (actualBuffer);
566566 }
567567
568+ static int isBinary (char * attrname) {
569+ if (!strcmp (attrname, " jpegPhoto" ) ||
570+ !strcmp (attrname, " photo" ) ||
571+ !strcmp (attrname, " personalSignature" ) |
572+ !strcmp (attrname, " userCertificate" ) ||
573+ !strcmp (attrname, " cACertificate" ) ||
574+ !strcmp (attrname, " authorityRevocationList" ) ||
575+ !strcmp (attrname, " certificateRevocationList" ) ||
576+ !strcmp (attrname, " deltaRevocationList" ) ||
577+ !strcmp (attrname, " crossCertificatePair" ) ||
578+ !strcmp (attrname, " x500UniqueIdentifier" ) ||
579+ !strcmp (attrname, " audio" ) ||
580+ !strcmp (attrname, " javaSerializedObject" ) ||
581+ !strcmp (attrname, " thumbnailPhoto" ) ||
582+ !strcmp (attrname, " thumbnailLogo" ) ||
583+ !strcmp (attrname, " supportedAlgorithms" ) ||
584+ !strcmp (attrname, " protocolInformation" ) ||
585+ strstr (attrname, " ;binary" )) {
586+ return 1 ;
587+ }
588+ return 0 ;
589+ }
590+
568591
569592 Local<Value> parseReply (LDAPConnection * c, LDAPMessage * msg)
570593 {
@@ -639,24 +662,10 @@ class LDAPConnection : public ObjectWrap
639662 js_attr_vals = Array::New (num_vals);
640663 js_result->Set (String::New (attrname), js_attr_vals);
641664
665+ int bin = c->isBinary (attrname);
666+
642667 for (int i = 0 ; i < num_vals && vals[i] ; i++) {
643- if (!strcmp (attrname, " jpegPhoto" ) ||
644- !strcmp (attrname, " photo" ) ||
645- !strcmp (attrname, " personalSignature" ) |
646- !strcmp (attrname, " userCertificate" ) ||
647- !strcmp (attrname, " cACertificate" ) ||
648- !strcmp (attrname, " authorityRevocationList" ) ||
649- !strcmp (attrname, " certificateRevocationList" ) ||
650- !strcmp (attrname, " deltaRevocationList" ) ||
651- !strcmp (attrname, " crossCertificatePair" ) ||
652- !strcmp (attrname, " x500UniqueIdentifier" ) ||
653- !strcmp (attrname, " audio" ) ||
654- !strcmp (attrname, " javaSerializedObject" ) ||
655- !strcmp (attrname, " thumbnailPhoto" ) ||
656- !strcmp (attrname, " thumbnailLogo" ) ||
657- !strcmp (attrname, " supportedAlgorithms" ) ||
658- !strcmp (attrname, " protocolInformation" ) ||
659- strstr (attrname, " ;binary" )) {
668+ if (bin) {
660669 js_attr_vals->Set (Integer::New (i), c->makeBuffer (vals[i]));
661670 } else {
662671 js_attr_vals->Set (Integer::New (i), String::New (vals[i]->bv_val ));
0 commit comments