检查用户是否在活动目录中被禁用

时间:2023-02-01 02:57:33

I am trying to find a way to check if the user is enabled or disabled in the active directory. I will be checking different domains if the user status is enable or disable. Trying searching around but not able to find any hints how can i accomplish this.

我试图找到一种方法来检查用户是否在活动目录中启用或禁用。如果用户状态为启用或禁用,我将检查不同的域。尝试搜索但无法找到任何提示我如何才能实现此目的。

I just need boolean value, for example if user is disabled bool method should return true if not false.

我只需要布尔值,例如,如果用户被禁用,bool方法应该返回true,如果不是false。

2 个解决方案

#1


Try using the answer here: get user names in an Active Directory Group via .net

尝试使用此处的答案:通过.net获取Active Directory组中的用户名

If that fails, use this link information: https://msdn.microsoft.com/en-us/magazine/cc135979.aspx#S8

如果失败,请使用此链接信息:https://msdn.microsoft.com/en-us/magazine/cc135979.aspx#S8

And last , you can refer here: http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C#39

最后,你可以参考这里:http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C#39

I hope it will solve your issue.

我希望它能解决你的问题。

#2


You can inspect the userAccountControl bit flag attribute. Its 2nd bit indicates if a user is disabled You can get this by using attributes. eg. (userAccountControl:1.2.840.113556.1.4.803:=2) filter will gives you all users list which are disabled.

您可以检查userAccountControl位标志属性。它的第2位表示用户是否被禁用您可以使用属性来获取此信息。例如。 (userAccountControl:1.2.840.113556.1.4.803:= 2)过滤器将为您提供已禁用的所有用户列表。

#1


Try using the answer here: get user names in an Active Directory Group via .net

尝试使用此处的答案:通过.net获取Active Directory组中的用户名

If that fails, use this link information: https://msdn.microsoft.com/en-us/magazine/cc135979.aspx#S8

如果失败,请使用此链接信息:https://msdn.microsoft.com/en-us/magazine/cc135979.aspx#S8

And last , you can refer here: http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C#39

最后,你可以参考这里:http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C#39

I hope it will solve your issue.

我希望它能解决你的问题。

#2


You can inspect the userAccountControl bit flag attribute. Its 2nd bit indicates if a user is disabled You can get this by using attributes. eg. (userAccountControl:1.2.840.113556.1.4.803:=2) filter will gives you all users list which are disabled.

您可以检查userAccountControl位标志属性。它的第2位表示用户是否被禁用您可以使用属性来获取此信息。例如。 (userAccountControl:1.2.840.113556.1.4.803:= 2)过滤器将为您提供已禁用的所有用户列表。