userprincipal

Looking for a Full S.DS.AM Sample with many AD extensions already written

空扰寡人 提交于 2019-12-13 01:43:58
问题 System.DirectoryServices.AccountManagement can be extended to support additional properties for reading and writing AD properties. Is anyone aware of a full/complete sample implementation that works for AD, Exchange 2003 or 2010? 回答1: There isn't anything online that I know of, but you are welcome to my collection (which I've included). One thing you'll probably notice about my code is that I've almost completely replaced the standard get/set operations with my own code which writes directly

Problems with extending s.ds.am.UserPrincipal class

☆樱花仙子☆ 提交于 2019-12-13 01:36:01
问题 I have been trying to extend the s.ds.am.UserPrincipal class in VS 2010 VB app as I require access to AD User properties that are not by default a part of the UserPrincipal. This is a new concept to me and I have found some useful code on here as well but I have run into 2 problems with my extensions that I cannot seem to figure out. Problem 1: When I attempt to use my UserPrincipalEx to retrieve a user I receive the following error. ERROR: Principal objects of type MyApp.UserPrincipalEx can

GetAuthorizationGroups returns more groups than my user is in

*爱你&永不变心* 提交于 2019-12-11 11:38:47
问题 i found this post to get the security groups of a user. I had to change it a bit so it looks like this: public List<GroupPrincipal> GetGroups(string userName, string userPassword, string userDomain) { List<GroupPrincipal> result = new List<GroupPrincipal>(); // establish domain context PrincipalContext yourDomain = new PrincipalContext(ContextType.Domain, userDomain, userName, userPassword); // find your user UserPrincipal user = UserPrincipal.FindByIdentity(yourDomain, IdentityType

Getting error while finding AD Groups of a user using PrincipalContext

Deadly 提交于 2019-12-11 05:30:01
问题 I have a situation where I need to find AD groups of a user recursively. For Example : I have such group hierarchy - Group1 |_ Group2 |_ Group3 |_ UserA According to the hierarchy, Groups of UserA are Group1, Group2, Group3 For finding it through the code I have used following method : Dim UserP1 As UserPrincipal = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, Remote_ID) allrecursiveUserGroups = UserP1.GetAuthorizationGroups() This method would give me all the groups

Getting EmailAddress NULL from Active Directory (AccountManagement UserPrincipal)

落爺英雄遲暮 提交于 2019-12-11 04:59:47
问题 I have a problem and can not find solution: I have the code below to retrieve the e-mail ( EmailAddress ) user that is accessing the web application. var pc = new System.DirectoryServices.AccountManagement.PrincipalContext(System.DirectoryServices.AccountManagement.ContextType.Domain); var user = System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(pc, System.DirectoryServices.AccountManagement.IdentityType.SamAccountName, username.ToLower()); email = user.EmailAddress; For

How to Get Current User Principal

感情迁移 提交于 2019-12-11 03:32:25
问题 I want to use Windows Authentication and get User info such as Givenname, Surname, etc. I used UserPrincipal.Current in IIS and I got an exception, but IIS express looks fine. 回答1: I solved by using a Find Method: var domain = new PrincipalContext(ContextType.Domain); var currentUser = UserPrincipal.FindByIdentity(domain, User.Identity.Name); 来源: https://stackoverflow.com/questions/21538184/how-to-get-current-user-principal

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

时光怂恿深爱的人放手 提交于 2019-12-09 17:07:34
问题 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

The LDAP Server is Unavailable using PrincipalContext and ADLDS

雨燕双飞 提交于 2019-12-05 13:35:33
We are making use of ADLDS for our user management and authentication. We can successfully query the instance without problems. However, trying to perform an operation such as SetPassword will fail or even trying to create a new user if a password is not set, it fails. I can successfully update a user as long as its not password I'm trying to update. I've been reading a lot of different articles relating to this but not finding a resolution. Posting to see if I can get some fresh perspective on this issue, thanks for any input. EXAMPLE ContextType ctxType = ContextType.ApplicationDirectory;

Search Users in Active Directory based on First Name, Last Name and Display Name

瘦欲@ 提交于 2019-12-04 18:44:28
I trying to search my organization Active directory for users. If the FirstName or LastName or DisplayName matches a particular string value, it should return the users. My Code: // create your domain context PrincipalContext ctx = new PrincipalContext(ContextType.Domain); UserPrincipal qbeUser = new UserPrincipal(ctx); qbeUser.GivenName = "Ramesh*"; // qbeUser.Surname = "Ramesh*"; // qbeUser.DisplayName= "Ramesh*"; PrincipalSearcher srch = new PrincipalSearcher(qbeUser); // find all matches foreach(var found in srch.FindAll()) { // } The problem is that I am able to search by only one filter.

ASP.NET MVC Windows Authentiaction and DirectoryServices - Get Mail Address of the current user throws an InvalidCastException

℡╲_俬逩灬. 提交于 2019-12-04 10:10:41
I am using ASP.NET MVC 4 and Windows Authentication. When I am using VisualStudio everything works fine, but when I deploy my site an exception is thrown. var emailAddress = UserPrincipal.Current.EmailAddress; throws: Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'. The rest works fine. Users can authenticate and I can get the users name etc. EDIT: I enabled Impersonation on IIS. Now I get the following exception: [DirectoryServicesCOMException (0x80072020): An operations error occurred