userprincipal

How I get Active Directory User Properties with System.DirectoryServices.AccountManagement Namespace?

本秂侑毒 提交于 2019-12-04 04:36:18
I want do get Active Directory Properties from a user and I want to use System.DirectoryServices.AccountManagement . my code: public static void GetUserProperties(string dc,string user) { PrincipalContext ctx = new PrincipalContext(ContextType.Domain, dc); UserPrincipal u = UserPrincipal.FindByIdentity(ctx, user); string firstname = u.GivenName; string lastname = u.Surname; string email = u.EmailAddress; string telephone = u.VoiceTelephoneNumber; ...//how I can get company and other properties? } You can transition into the DirectoryServices namespace to get any property you need.

Get nETBIOSName from a UserPrincipal object

心不动则不痛 提交于 2019-11-30 12:20:20
I am using the System.DirectoryServices.AccountManagement part of the .Net library to interface into ActiveDirectory. Having called GetMembers() on a GroupPrincipal object and filter the results, I now have a collection of UserPrincipal objects GroupPrincipal myGroup; // population of this object omitted here foreach (UserPrincipal user in myGroup.GetMembers(false).OfType<UserPrincipal>()) { Console.WriteLine(user.SamAccountName); } The above code sample will print out usernames like "TestUser1". I need to compare these to a list coming from another application in "DOMAIN\TestUser1" format.

Get nETBIOSName from a UserPrincipal object

∥☆過路亽.° 提交于 2019-11-29 17:39:48
问题 I am using the System.DirectoryServices.AccountManagement part of the .Net library to interface into ActiveDirectory. Having called GetMembers() on a GroupPrincipal object and filter the results, I now have a collection of UserPrincipal objects GroupPrincipal myGroup; // population of this object omitted here foreach (UserPrincipal user in myGroup.GetMembers(false).OfType<UserPrincipal>()) { Console.WriteLine(user.SamAccountName); } The above code sample will print out usernames like

How to search for users in Global Catalog within AD forest with multiple trees

那年仲夏 提交于 2019-11-29 07:09:54
I have the following AD forest with two trees: Domain1. Has two child domains Domain2 and Domain3 Domain4. Doesn't have child domains. DNS name of the Domain1 is domain1.local . DNS name of the Domain4 is domain4.local . In each domain there is a domain controller with Global Catalog enabled. I'm trying to get UserPrincipal for the user from Domain 4 by its SID. The program runs from a machine in Domain2. I use the following code: // Running on some machine from Domain2 PrincipalContext context = new PrincipalContext( ContextType.Domain, "dc2.domain2.domain1.local:3268", // Using Global

How to get number of connected users and their role using j_security_check?

眉间皱痕 提交于 2019-11-28 05:08:30
I get the username of the connected user (using j_security_check) this way, through a managed bean: ...... username = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal().getName(); And then display it in a jsf page this way : #{userBean.username} But I figured no way to get the number of connected users and get their role. In other words, I want to display besides the username, the user role and the number of connected users. How can I achieve this!? Thanks in advance for your help! EDIT: I can now get the Role of the connected user, using a namedquery in a managed bean :

How can I get a list Local Windows Users (Only the Users that appear in the windows Logon Screen)

我的未来我决定 提交于 2019-11-28 01:52:12
How can I get a list of Local Windows Users (Only the Users that appear in the windows Logon Screen) I have tried many methods using Windows Principle library & WMI Select commands. I keep getting Administrator, Guest & some other bizarre accounts (VUSRNEIL-DELL, $HOMEGROUPUSER, ASPNET...etc.) Neither of these 3 user accounts appear on the Logon screen. How can I Differentiate between these user types? I am coding in C# Leniel Maccaferri Just add a reference to System.Management in a Console Application and try this code: using System; using System.Management; using System.Linq; namespace

Determine if user is in AD group for .NET 4.0 application

笑着哭i 提交于 2019-11-27 14:05:25
问题 I am trying to determine if a user is a member of an Active Directory (AD) group for an internal ASP.NET 4.0 application. The code below throws an "Attempted to access an unloaded appdomain" exception error on the last line (return statement) in the case when the user is not a member of the AD group. public static bool IsInADGroup(string userName, string groupName) { var principalContext = new PrincipalContext(ContextType.Domain); UserPrincipal userPrincipal = UserPrincipal.FindByIdentity

Get the list of Groups for the given UserPrincipal

别来无恙 提交于 2019-11-27 06:47:29
问题 I want to get the list of groups which the user is in. This is my code: PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "mydomain.ac.uk", "DC=mydomain,DC=AC,DC=UK", "user", "password"); UserPrincipal user = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, "MyUser"); PrincipalSearchResult<Principal> results = user.GetGroups(); foreach(Principal p in results) { Response.Write(p.Name); } When I run, I got the following error at the line Response.Write(p.Name);

How can I get a list Local Windows Users (Only the Users that appear in the windows Logon Screen)

被刻印的时光 ゝ 提交于 2019-11-27 04:50:47
问题 How can I get a list of Local Windows Users (Only the Users that appear in the windows Logon Screen) I have tried many methods using Windows Principle library & WMI Select commands. I keep getting Administrator, Guest & some other bizarre accounts (VUSRNEIL-DELL, $HOMEGROUPUSER, ASPNET...etc.) Neither of these 3 user accounts appear on the Logon screen. How can I Differentiate between these user types? I am coding in C# 回答1: Just add a reference to System.Management in a Console Application

How to get number of connected users and their role using j_security_check?

旧街凉风 提交于 2019-11-27 00:48:40
问题 I get the username of the connected user (using j_security_check) this way, through a managed bean: ...... username = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal().getName(); And then display it in a jsf page this way : #{userBean.username} But I figured no way to get the number of connected users and get their role. In other words, I want to display besides the username, the user role and the number of connected users. How can I achieve this!? Thanks in advance