我正在使用.Net库的System.DirectoryServices.AccountManagement部分连接到ActiveDirectory.
在GroupPrincipal对象上调用GetMembers()并过滤结果后,我现在有一个UserPrincipal对象的集合
GroupPrincipal myGroup; // population of this object omitted here
foreach (UserPrincipal user in myGroup.GetMembers(false).OfType<UserPrincipal>())
{
Console.WriteLine(user.SamAccountName);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码示例将打印出"TestUser1"之类的用户名.我需要将这些与来自"DOMAIN\TestUser1"格式的另一个应用程序的列表进行比较.
如何从UserPrincipal对象获取"DOMAIN"部分?
我不能只是附加一个已知的域名,因为涉及多个域,我需要区分DOMAIN1\TestUser1和DOMAIN2\TestUser2.
我在python中编写了一个函数,例如返回一个列表
[(1,1),(2,2),(3,3)]
Run Code Online (Sandbox Code Playgroud)
但我希望输出为一个字符串,所以我可以用另一个char替换逗号,所以输出将是
'1@1' '2@2' '3@3'
Run Code Online (Sandbox Code Playgroud)
有什么简单的方法吗?:)感谢提前的任何提示
我的Java应用程序使用.mdb数据库,我想在MAC OS上运行这个应用程序,这肯定会有一个TYPE 4 JDBC驱动程序,我有谷歌,并遇到了两个 - HXTT和StelsMDB,但两者都超出我的范围
因此,如果任何机构有一些替代或建议,请回复.
提前致谢
我想知道它们之间的区别ObservableCollection,BindingList因为我已经使用了两者来通知Source中的任何添加/删除更改,但实际上我不知道何时更喜欢一个而不是另一个.
为什么我会选择以下其中一个而不是另一个?
ObservableCollection<Employee> lstEmp = new ObservableCollection<Employee>();
Run Code Online (Sandbox Code Playgroud)
要么
BindingList<Employee> lstEmp = new BindingList<Employee>();
Run Code Online (Sandbox Code Playgroud) 当我尝试在区域中的控制器中打开视图时,我得到了上述内容.Ninject设置如下:
public class NinjectControllerFactory : DefaultControllerFactory
{
private IKernel kernel = new StandardKernel(new RLSBCWebSiteServices());
protected override IController GetControllerInstance(RequestContext context, Type controllerType)
{
if (controllerType == null)
return null;
return (IController)kernel.Get(controllerType);
}
private class MyWebSiteServices : NinjectModule
{
public override void Load()
{
Bind<IMatchesRepository>().To<SqlMatchesRepository>().WithConstructorArgument("connectionString",
ConfigurationManager.ConnectionStrings["MyWebSiteDb"].ConnectionString);
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果我在代码中放置断点,我看到RequestContext上下文包含以下值:
context.RouteData.DataTokens.Values[0] = “MyWebSite.WebUI.Areas.Visitor” context.RouteData.DataTokens.Values[1] = “Visitor” which is the Area
context.RouteData.Values.Values[0] = “admin” which is the Controller
context.RouteData.Values.Values[1] = “register” which is the View
Run Code Online (Sandbox Code Playgroud)
但是,controllerType == null,而不是控制器名称.
这个转移到新页面的过程是由
Html.ActionLink("here", "Register", "Admin", new …Run Code Online (Sandbox Code Playgroud) 我有一组字符串[].我想检查这个Set是否包含另一个String [].
Set<String[]> s = new HashSet<String[]>();
s.add(new String[] {"lucy", "simon"});
System.out.println(s.contains(new String[] {"lucy", "simon"}));
Run Code Online (Sandbox Code Playgroud)
但是,打印为false.我猜这是因为只有引用被比较而不是实际的字符串.看来,我唯一的选择是创建一个类,比如Phrase,并实现hashCode()和equals()(使用Arrays.hashCode(...)).
有没有其他方法可以实现我想要的?
如何在iText文档中添加新页面?document.newPage();似乎不起作用.
我正在使用来自http://sourceforge.net/projects/itextrtf/的支持RTF的iText
我的部分代码:
Font titleFont = new Font(Font.COURIER, 14, Font.BOLD);
document.add(new Paragraph("Title1", titleFont));
Table table = new Table(4);
table.setBorderWidth(0);
// Filling table
document.add(table);
document.newPage();
document.add(new Paragraph("Title2", titleFont));
Table table = new Table(4);
table.setBorderWidth(0);
// Filling table
document.add(table);
Run Code Online (Sandbox Code Playgroud) 我正在struts中实现一个项目,我在JSP页面中收到错误.
我已经在Eclipce IDE中配置了Tomcat 6,JRE和JDK 6.
代码是:
%request.getContextPath()%
Run Code Online (Sandbox Code Playgroud)
错误是:
The method getContextPath() from the type HttpServletRequest refers to the missing type String
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个错误?
什么时候存储双打才有意义?假设您从十进制符号CSV中读取数据(例如,使用诸如"5.03"之类的值),使用mysql的DOUBLE类型是否有意义?不会有不必要的舍入错误吗?
我有一个问题FxCop和警告:Abstract types should not have constructors.
这是为许多抽象类显示的(可能所有,我还没有检查过).当我看起来他们中的大多数没有新的方法所以我认为它是编译器添加默认方法.所以要删除它我添加一个私有默认Private Sub New()的constuctor (),这意味着所有的inherting类都无法构建错误:
Class 'InheritingClass' has no accessible 'Sub New' and cannot be inherited.
这似乎很奇怪,因为FxCop请求没有公共构造函数,但是当我删除它时,构建失败.