我正在寻找一种方法来创建Active Directory用户并设置他们的密码,最好不要给我的应用程序/服务域管理员权限.
我尝试过以下方法:
DirectoryEntry newUser = _directoryEntry.Children.Add("CN=" + fullname, USER);
newUser.Properties["samAccountName"].Value = username;
newUser.Properties["userPassword"].Value = password;
newUser.Properties["mail"].Value = email;
newUser.CommitChanges();
Run Code Online (Sandbox Code Playgroud)
用户已创建,但似乎从未在用户上设置密码.
有没有人知道如何在创建用户时最初设置用户密码?我知道
.Invoke("SetPassword", new object[] { password })
Run Code Online (Sandbox Code Playgroud)
但这需要我的代码以域管理员权限运行.因为我没有真正看到授予我的代码域管理员权限的重点,只是设置初始密码(我也允许用户密码重置,但那些在特定用户的上下文中运行),我希望有人聪明解决方案,不要求我这样做.
提前致谢!
我正在尝试使用以下代码在XmlDocument中按名称查找节点:
private XmlNode FindNode(XmlNodeList list, string nodeName)
{
if (list.Count > 0)
{
foreach (XmlNode node in list)
{
if (node.Name.Equals(nodeName)) return node;
if (node.HasChildNodes) FindNode(node.ChildNodes, nodeName);
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
我用以下函数调用该函数:
FindNode(xmlDocument.ChildNodes, "somestring");
Run Code Online (Sandbox Code Playgroud)
由于某种原因,它总是返回null,我不确定为什么.有人可以帮我解决这个问题吗?
我正在尝试从Windows 8 SDK示例中创建与ScrollViewerSample类似的体验,以便能够在向左和向右滚动时捕捉到ScrollViewer内的项目.样本(有效)的实现是这样的:
<ScrollViewer x:Name="scrollViewer" Width="480" Height="270"
HorizontalAlignment="Left" VerticalAlignment="Top"
VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto"
ZoomMode="Disabled" HorizontalSnapPointsType="Mandatory">
<StackPanel Orientation="Horizontal">
<Image Width="480" Height="270" AutomationProperties.Name="Image of a cliff" Source="images/cliff.jpg" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Image Width="480" Height="270" AutomationProperties.Name="Image of Grapes" Source="images/grapes.jpg" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Image Width="480" Height="270" AutomationProperties.Name="Image of Mount Rainier" Source="images/Rainier.jpg" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Image Width="480" Height="270" AutomationProperties.Name="Image of a sunset" Source="images/sunset.jpg" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Image Width="480" Height="270" AutomationProperties.Name="Image of a valley" Source="images/valley.jpg" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</StackPanel>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)
与我期望的实现的唯一区别是我不希望StackPanel内部有项目,但是我可以绑定它.我试图用ItemsControl完成这个,但由于某种原因,Snap行为没有启动:
<ScrollViewer x:Name="scrollViewer" Width="480" Height="270"
HorizontalAlignment="Left" VerticalAlignment="Top"
VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto" …Run Code Online (Sandbox Code Playgroud) 我正在尝试以编程方式在WPF控件上手动触发MouseLeftButtonDown事件,因为我使用的是Microsoft Surface SDK,它不会触发MouseLeftButtonDown事件,而是触发ContactDown事件.基本上我正在尝试将MouseLeftButtonDown事件向下推送到控件,以在处理ContactDown事件时触发控件上的正确行为.
我猜我必须以某种方式使用控件上的RaiseEvent方法来实现MouseButtonEventArgs,但是我在查找参数时遇到了一些麻烦.
在此先感谢您的帮助!
我正在制作一个Windows Phone 7应用程序,它涉及从Web获取大图像并将其放入ScrollViewer供用户滚动.不过,我认为我正在受到限制BitmapImage,因为图像似乎在高度或宽度上都被切割成2048像素.
这是Silverlight的已知限制BitmapImage吗?在这种情况下是否允许使用其他类来滚动大图像?
谢谢
我有一种情况,我正在使用的API返回不一致的JSON,我想使用JSON.NET反序列化.在一种情况下,它返回一个包含对象的对象(注意外部"1"可以是任何数字):
{
"1":{
"0":{
"db_id":"12835424",
"title":"XXX"
},
"1":{
"db_id":"12768978",
"title":"YYY"
},
"2":{
"db_id":"12768980",
"title":"ZZZ"
},
"3":{
"db_id":"12768981",
"title":"PPP"
}
}
}
Run Code Online (Sandbox Code Playgroud)
在另一种情况下,它返回一个对象数组:
{
"3":[
{
"db_id":"12769199",
"title":"XXX"
},
{
"db_id":"12769200",
"title":"YYY"
},
{
"db_id":"12769202",
"title":"ZZZ"
},
{
"db_id":"12769243",
"title":"PPP"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会出现这种不一致,但这是我正在使用的格式.使用该JsonConvert.DeserializeObject方法对这两种格式进行反序列化的正确方法是什么?
c# ×3
.net ×1
bitmapimage ×1
json.net ×1
raiseevent ×1
silverlight ×1
windows-8 ×1
winrt-xaml ×1
wpf ×1
xaml ×1
xmldocument ×1