if(UserName == null) { ent = new DirectoryEntry(entPath); } else { // ent = new DirectoryEntry(entPath, HostName+"//"+UserName, Password, AuthenticationTypes.Secure); ent = new DirectoryEntry(entPath, UserName, Password, AuthenticationTypes.Secure); }