在Active Directory中重置用户密码后,如果用户尝试使用旧密码登录,则以下代码验证为True:
Dim up As UserPrincipal = GetAdUser(objContext, arg_strBA, arg_strUsername)
If up IsNot Nothing Then
Dim valid As Boolean = up.Context.ValidateCredentials(
up.UserPrincipalName, arg_strPassword, ContextOptions.Negotiate)
If (valid) Then strReturn = up.SamAccountName
End If
Run Code Online (Sandbox Code Playgroud)
我们正在使用以下代码重置密码:
Dim objUser As New DirectoryEntry(arg_strLDAPPath)
If Not objUser Is Nothing Then
objUser.AuthenticationType = AuthenticationTypes.Secure
objUser.Invoke("SetPassword", arg_strNewPW)
objUser.CommitChanges()
end if
Run Code Online (Sandbox Code Playgroud)
密码重置工作正常,用户可以使用新密码登录,但旧密码仍不能验证.
当上述ValidateCredentials适用于旧密码时,我们将凭据分配给Web服务调用,然后失败并显示"401:Unauthorized"错误.
有人见过这样的事吗?
谢谢Dirk
当用户在我的应用程序中创建新帐户时,我在android客户经理中创建新帐户.因此用户可以在设置 - >帐户和同步中查看他的帐户...
所以问题:当用户点击帐户中的"添加新帐户"并同步时,是否可以从列表中删除我的应用程序?用户不应该在此列表中看到我的应用,但仍可以在我的应用中创建帐户.
PS.点击添加帐户时我不想打开活动,我只是不想在列表中显示我的应用点.
我有我的清单:
<service
android:name="myPackage.authenticator.AuthenticationService"
android:exported="false" >
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
Run Code Online (Sandbox Code Playgroud)
我的身份验证员:
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="myType"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:smallIcon="@drawable/ic_launcher" />
Run Code Online (Sandbox Code Playgroud) 我已成功创建各种帐户验证器/服务,每个帐户验证器/服务都有自己的preference.xml.这些偏好是持久的,但我不知道它们存储在手机的哪个位置.我使用adb搜索了手机,但我似乎无法找到与我的特定帐户的首选项对应的*.db或"shared_prefs"文件.
有人有这方面的经验吗?
我使用本教程成功将外部联系人导入新创建的帐户.该帐户设置为以编程方式重新同步,但是,为了能够看到同步的联系人, - 除非找到联系人欺骗 - 我需要这样做Contacts->Menu->Display options->Find account->Check "All Contacts".我已经害怕愤怒的用户启用联系人同步而无法看到任何内容所以问题是:是否可以设置显示选项以包含导入的帐户联系人?因此,当用户选择创建帐户时,他不需要执行任何其他操作来查看导入的联系人?
我是新手访问Active Directory,我被建议使用,System.DirectoryServices.AccountManagement但我找不到initials变量任何帮助?
...而我们只在Microsoft.AspNet.Identity中.(我们甚至没有查看Microsoft.AspNet.Identity.EntityFramework的基本实现.)
该UserManager班只需要在一个IUserStore<TUser>在构造函数中.它没有IUserRoleStore<TUserRole>我想象的需要访问以确定是否UserManager.IsInRoleAsync(string, string).
我认为UserStore的实现也会有一个IsInRoleAsync(string, string)功能(然后它会都有意义),但事实并非如此.
另一个奇怪的事情 - 如果UserManager在其实现中知道所有内容,那么UserManager如何才能执行密码设置和重置?我们正在处理IUser- 仅使用string Id和string UserName作为属性?
我正在尝试列出给定用户所属的所有组,并且我想同时支持本地计算机帐户和域帐户。我可以使用以下代码获取域帐户的组:
public void ListAllGroupsDomain()
{
ListAllGroups(ContextType.Domain,
"myDomain",
"myDomainUser",
"myDomainPassword");
}
public void ListAllGroups(ContextType contextType
string name,
string username,
string password)
{
using (var context = new PrincipalContext(contextType,
name,
username,
password))
{
using (var findByIdentity = UserPrincipal.FindByIdentity(context, "testedit"))
{
if (findByIdentity != null)
{
var groups = findByIdentity.GetGroups(context);
var results = groups.Select(g => g.Name).ToArray();
Console.WriteLine("Listing {0} groups", results.Count());
foreach (var name in results)
{
Console.WriteLine("{0}", name);
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试调用机器本地的帐户,我会收到一个 COM 异常,说我的用户名或密码不正确(它们不是):
public void ListAllGroupsMachine()
{
ListAllGroups(ContextType.Machine,
"myMachine",
"myMachineUser", …Run Code Online (Sandbox Code Playgroud) 我System.DirectoryServices.AccountManagement用来查询用户,然后找到该用户的组.
var _principalContext = new PrincipalContext(ContextType.Domain, domainAddress, adContainer, adQueryAccount, adQueryAccountPassword);
var user = UserPrincipal.FindByIdentity(_principalContext, IdentityType.SamAccountName, account);
var userGroups = user.GetGroups();
foreach (var group in userGroups.Cast<GroupPrincipal>())
{
//////////////////////////////////////////////////////
// getting the underlying DirectoryEntry shown
// to demonstrate that I can retrieve the underlying
// properties without the exception being thrown
DirectoryEntry directoryEntry = group.GetUnderlyingObject() as DirectoryEntry;
var displayName = directoryEntry.Properties["displayName"];
if (displayName != null && displayName.Value != null)
Console.WriteLine(displayName.Value);
//////////////////////////////////////////////////////
Console.WriteLine(group.DisplayName);// exception thrown here...
}
Run Code Online (Sandbox Code Playgroud)
我可以获取底层DirectoryEntry对象并转储其属性和值,但只要GroupPrincipal.DisplayName …
我正在开发一个画廊,允许用户发布照片,评论,投票和做许多其他任务.
现在我认为允许用户取消订阅并删除所有数据是正确的.但是很难允许这样的事情,因为你冒着破坏你的应用程序的风险(例如,当评论有很多回复时我该怎么办?对于那些由不同用户进行多次修改的页面,我该怎么做?).
照片可以轻松删除,但对于其他数据(即评论,修订......)我认为有三种可能性:
当我们允许用户删除其帐户时,要遵循哪些最佳做法?你如何实现它们(特别是在Rails中)?
我试图在 ActiveDirectory 内的特定 OU 中创建一个新的 UserPrincipal,它返回一个异常,并显示消息“对象已存在”。(显然)该用户不存在于该 OU 中,并且我正在测试它的存在。
我究竟做错了什么?
这是抛出异常的代码:
public UserPrincipal CreateUser(string username, string pass,
string givenName, string surname) {
PrincipalContext context = this.principalContext;
UserPrincipal user = new UserPrincipal(context);
user.SamAccountName = username;
user.UserPrincipalName = username;
user.GivenName = givenName;
user.Surname = surname;
user.SetPassword(pass);
user.Save();
return user;
}
Run Code Online (Sandbox Code Playgroud)
编辑1:经过单元测试,我发现代码没问题。我在 lib(运行测试的地方)中使用此方法,该方法由另一个启用了 Windows 身份验证模式的应用程序调用。也许应用程序正在将该身份验证发送到 AD?
我正在尝试扩展SampleSync应用程序.安装应用程序后,我可以进入设置 - >帐户和同步 - >添加帐户以添加帐户.但是,如果我想从我的应用程序代码中检查并希望触发AccountManager直接添加新帐户,那么最佳方法是什么?
是否有可用于管理用户帐户的meteor.js库?
我想让用户注册,可以访问唯一的用户ID来限制单个用户可以执行某些操作的次数,还有不同的用户层来控制访问权限.如果我不必自己建立这个就好了.