LDAP Query返回包含特定属性的用户列表

时间:2018-04-27 13:11:19

标签: ldap ldap-query

在这个OU=Employees,OU=Users,DC=org,DC=com中我有一个CN列表(user1,user2,user3。每个CN(用户)包含一个属性列表(isUseless,managerid等)

我想获取所有CN员工的列表,其属性为isUseless=Yes

我已经在网上搜索并阅读了无数的教程,但我很难理解这里的一些基本概念。如果有人能为我打破解决方案,我会非常乐意。

1 个答案:

答案 0 :(得分:0)

类似于以下内容的LDAP搜索过滤器:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <GL/glx.h>
#include <GL/glext.h>
#include <GL/glu.h>

Display *dpy;
Window root, win;
GLint att[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
XVisualInfo *vi;
Colormap cmap;
XSetWindowAttributes swa;
XWindowAttributes wa;
XEvent xev;
Mask mask;

float TimeCounter, LastFrameTimeCounter, DT, prevTime = 0.0, FPS;
struct timeval tv, tv0;
int Frame = 1, FramesPerFPS;

void CreateWindow() {
  if ((dpy = XOpenDisplay(NULL)) == NULL) {
    printf("\n\tcannot connect to x server\n\n");
    exit(0);
  }

  root = DefaultRootWindow(dpy);

  if ((vi = glXChooseVisual(dpy, 0, att)) == NULL) {
    printf("\n\tno matching visual\n\n");
    exit(0);
  }

  if ((cmap = XCreateColormap(dpy, root, vi->visual, AllocNone)) == 0) {
    printf("\n\tcannot create colormap\n\n");
    exit(0);
  }

  swa.event_mask = KeyPressMask;
  swa.colormap = cmap;
  win = XCreateWindow(dpy, root, 0, 0, 1024, 768, 0, vi->depth, InputOutput,
                      vi->visual, CWColormap | CWEventMask, &swa);
  XStoreName(dpy, win, "ed");
  XMapWindow(dpy, win);
}

void Close() {
  XDestroyWindow(dpy, win);
  XCloseDisplay(dpy);
  exit(0);
}

int main(int argc, char *argv[]) {
  CreateWindow();

  while (true) {
    mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask;
    while (XCheckWindowEvent(dpy, win, mask, &xev) ||
           XCheckTypedWindowEvent(dpy, win, ClientMessage, &xev)) {
      char *key_string =
          XKeysymToString(XkbKeycodeToKeysym(dpy, xev.xkey.keycode, 0, 0));

      if (strncmp(key_string, "Escape", 5) == 0) {
        Close();
      }
    }
  }
}

或所有具有cn值的条目:     (及(isUseless =是)(CN = *)) 或所有用户类型条目(在Microsoft Active Directory中:

(&(isUseless=Yes)(|(cn= user1)(cn= user1)(cn=user1)))

指定: 返回属性:“isUseless”“managerid”“etc” baseDN:OU = Employees,OU = Users,DC = org,DC = com

应该做的伎俩。

让我知道如何提供帮助。 -Jim