作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用ldap_search_s
( ldap_search_sW
) 提取 AD 用户组。当 attrs
时它起作用。参数( PZPWSTR
或 wchar_t**
)为 NULL
,但是当我尝试指定它时,我得到 Exception at 0x7ffc1885bd95, code: 0xc0000005: read access violation at: 0xfffffffffffffffe
.
wchar_t *attrs[] = {
const_cast<wchar_t *>(L"memberOf"),
const_cast<wchar_t *>(L"")
};
ret = ldap_search_s(pLdap, const_cast<wchar_t *>(dn.c_str()), LDAP_SCOPE_SUBTREE, const_cast<wchar_t *>(filter.c_str()), attrs, 0, &pSearchResult);
根据docs它需要是“一个以 null 结尾的字符串组成的数组,指示要为每个匹配条目返回的属性。传递 NULL 以检索所有可用属性。”
我尝试了使用 vector 、数组等的不同方法,但总是得到相同的错误。
The example in MSDN仅显示 ANSI 版本,但它似乎是一个非常相似的指针数组。
最佳答案
您的数组不是以 null 结尾的。 NULL 和空字符串不相同。
使用NULL
(或现代C++中的nullptr
)。
wchar_t *attrs[] = {
const_cast<wchar_t *>(L"memberOf"),
nullptr
};
关于c++ - 如何为 WinApi ldap_search_s 初始化 PZPWSTR (wchar_t**) 参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57878479/
我正在使用ldap_search_s ( ldap_search_sW ) 提取 AD 用户组。当 attrs 时它起作用。参数( PZPWSTR 或 wchar_t** )为 NULL ,但是当我尝
我是一名优秀的程序员,十分优秀!