我遇到了一些代码问题,这些代码旨在通过搜索他们的电子邮件地址来查找Active Directory中的用户.我尝试了2种方法,但有时我发现FindOne()方法在某些情况下不会返回任何结果.如果我在Outlook中的GAL中查找用户,我会看到列出的SMTP电子邮件地址.
我的最终目标是确认用户是否存在于AD中.我只有电子邮件地址作为搜索条件,因此无法使用名字或姓氏.
方法1:使用邮件属性:
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(mail=" + email + ")";
search.PropertiesToLoad.Add("mail");
SearchResult result = search.FindOne();
Run Code Online (Sandbox Code Playgroud)
方法2:proxyAddresses属性:
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(proxyAddresses=SMTP:" + email + ")"; // I've also tried with =smtp:
search.PropertiesToLoad.Add("mail");
SearchResult result = search.FindOne();
Run Code Online (Sandbox Code Playgroud)
我已经尝试更改电子邮件地址输入的大小写,但它仍然没有返回结果.这里是否存在区分大小写的问题?如果是这样,解决它的最佳方法是什么?
我相信我通过识别哪些字段应该是散列/相等测试的一部分来阅读在编译期间(使用APT)生成equals/hashcode/toString方法的人.我在网上找不到那样的东西(我可能梦见过它?)......
这可以这样做:
public class Person {
@Id @GeneratedValue private Integer id;
@Identity private String firstName, lastName;
@Identity private Date dateOfBirth;
//...
}
Run Code Online (Sandbox Code Playgroud)
对于一个实体(所以我们想要排除一些字段,比如id).
或者像scala案例类,即值对象:
@ValueObject
public class Color {
private int red, green, blue;
}
Run Code Online (Sandbox Code Playgroud)
不仅文件变得更易读和更容易编写,而且它还有助于确保所有属性都是equals/hashcode的一部分(如果您稍后添加其他属性,而不相应地更新方法).
我听说APT在IDE中得不到很好的支持,但我不认为这是一个主要问题.毕竟,测试主要由持续集成服务器运行.
有没有想过这是否已经完成,如果不是为什么?谢谢
我试图为传输函数块建模1 /(s + 1).在Simulink中为传递函数实现块的最简单方法是什么?
doGet()servlet中的一个非常简单的java代码在GAE上获得超过一秒的cpu时间.我已经阅读了一些与配额相关的文档,显然我没有做错任何事.
//Request the user Agent info
String userAgent = req.getHeader("User-Agent");
Run Code Online (Sandbox Code Playgroud)
我想知道最多使用CPU的是什么,我使用谷歌帮助推荐.
//The two lines below will get the CPU before requesting User-Agent Information
QuotaService qs = QuotaServiceFactory.getQuotaService();
long start = qs.getCpuTimeInMegaCycles();
//Request the user Agent info
String userAgent = req.getHeader("User-Agent");
//The three lines below will get the CPU after requesting User-Agent Information
// and informed it to the application log.
long end = qs.getCpuTimeInMegaCycles();
double cpuSeconds = qs.convertMegacyclesToCpuSeconds(end - start);
log.warning("CPU Seconds on geting User Agent: " + cpuSeconds);
Run Code Online (Sandbox Code Playgroud)
上面代码告诉我的唯一事情是检查标头将使用超过一秒(1000毫秒)的CPU时间,这对于Google来说是日志面板上的警告.这似乎是一个非常简单的请求,仍然使用超过一秒的CPU. …
我正在尝试使用一个简单的几何着色器,但是当在带有GMA X3100的笔记本电脑上的Shader Builder中运行时,它会退回并使用软件渲染.根据这份文件,GMA X3100确实支持EXT_geometry_shader4.
输入是POINTS,输出是LINE_STRIP.
让它在GPU上运行需要什么(如果可能的话)
uniform vec2 offset;
void main()
{
gl_Position = gl_PositionIn[0];
EmitVertex();
gl_Position = gl_PositionIn[0] + vec4(offset.x,offset.y,0,0);
EmitVertex();
EndPrimitive();
}
Run Code Online (Sandbox Code Playgroud) 我使用jquery load方法来更新div,它运行良好,直到我在IE6下测试我的代码.问题是:在IE6下,当我单击一个按钮来触发加载方法时,页面保持不变,直到我移动光标,这意味着如果我单击鼠标并将手远离鼠标,页面将保持不变,如果我移动鼠标,页面会更新.
这个问题只发生在IE6下.IE7,IE8,Firefox都没有问题.
你们有没有遇到过这种问题?
是否有一种"适当的"方式在C中实现更高阶的函数.
我对这里的可移植性和语法正确性等问题非常好奇,如果有多种方法,那么优点和缺点是什么.
编辑:我想知道如何创建更高阶函数的原因是我编写了一个系统来将PyObject列表(在调用python脚本时得到)转换为包含相同数据但以非方式组织的C结构列表依赖于python.h库.所以我的计划是有一个函数,它遍历pythonic列表并在列表中的每个项目上调用一个函数,并将结果放在一个列表中然后返回.
所以这基本上是我的计划:
typedef gpointer (converter_func_type)(PyObject *)
gpointer converter_function(PyObject *obj)
{
// do som stuff and return a struct cast into a gpointer (which is a void *)
}
GList *pylist_to_clist(PyObject *obj, converter_func_type f)
{
GList *some_glist;
for each item in obj
{
some_glist = g_list_append(some_glist, f(item));
}
return some_glist;
}
void some_function_that_executes_a_python_script(void)
{
PyObject *result = python stuff that returns a list;
GList *clist = pylist_to_clist(result, converter_function);
}
Run Code Online (Sandbox Code Playgroud)
并澄清问题:我想知道如何以更安全和更正确的方式做到这一点.我真的想保持更高阶的功能风格,但如果这是不赞成的话,我非常感谢以其他方式做到这一点.
所以,我有两个结构:
struct coordinate {
float x;
float y;
}
struct person {
int id;
coordinate location;
}
Run Code Online (Sandbox Code Playgroud)
以及在坐标上操作的函数:
float distance(const coordinate& c1, const coordinate& c2);
Run Code Online (Sandbox Code Playgroud)
在我的main方法中,我有以下代码:
map<int,person> people;
// populate people
map<int,map<float,int> > distance_map;
map<int,person>::iterator it1,it2;
for (it1=people.begin(); it1!=people.end(); ++it1) {
for (it2=people.begin(); it2!=people.end(); ++it2) {
float d = distance(it1->second.location,it2->second.location);
distance_map[it1->first][d] = it2->first;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我在构建时收到以下错误:
stl_iterator_base_types.h: In instantiation of ‘std::iterator_traits<coordinate>’:
stl_iterator_base_types.h:129: error: no type named ‘iterator_category’ in ‘struct coordinate’
stl_iterator_base_types.h:130: error: no type named ‘value_type’ in ‘struct coordinate’
stl_iterator_base_types.h:131: …Run Code Online (Sandbox Code Playgroud) Python列表推导很好,但几乎不可能调试.你们有任何好的技巧/工具来调试它们吗?
我正在构建一个carArray并希望有条件地过滤内容,使用NSPredicate如下:
NSPredicate *pred;
switch (carType) {
case FreeCar:
pred = [NSPredicate predicateWithFormat:@"premium = NO"];
break;
case PremiumCar:
pred = [NSPredicate predicateWithFormat:@"premium = YES"];
break;
default:
pred = [NSPredicate predicateWithFormat:@"SOME PREDICATE THAT RETURNS EVERYTHING"];
break;
}
self.carArray = [aCarArrayIGotFromSomewhere filteredArrayUsingPredicate:pred];
Run Code Online (Sandbox Code Playgroud)
我的问题是,我存在的值的正确语法是什么,SOME PREDICATE THAT RETURNS EVERYTHING它返回数组/集中的所有实例?