I am trying to get extra user information from AD.
List<string> allUsers = new List<string>();
PrincipalContext ctx2 = new PrincipalContext(ContextType.Domain, "FUNDACION", valor);
UserPrincipal qbeUser2 = new UserPrincipal(ctx2);
qbeUser2.Enabled = true; // activo para autenticacion
PrincipalSearcher srch2 = new PrincipalSearcher(qbeUser2);
srch2.QueryFilter = qbeUser2;
DirectoryEntry dirEntry = (qbeUser2.GetUnderlyingObject() as DirectoryEntry);
I am getting an exception at this line :
DirectoryEntry dirEntry = (qbeUser2.GetUnderlyingObject() as DirectoryEntry);
An exception of type 'System.InvalidOperationException' occurred in System.DirectoryServices.AccountManagement.dll but was not handled in user code Additional information: The Principal object must be persisted before this method can be called.