Reputation: 386
I´m working with ActiveDirectory for a login and after the user is validate i will get all the values from that user but i dont know if is possible get the computers managed by that user.
My login and find user data is working this way:
var ActiveDirectory = require('activedirectory');
var {ConfigActiveDirectory} = require('./ConfigActiveDirectory.js');
var ad = new ActiveDirectory(ConfigActiveDirectory);
//Valida login y usuario en el dominio.
const ValidateLogin = (username,password,callback) =>{
var username = username;
var password = password;
ad.authenticate(username, password, function(err, auth) {
if (err) {
return callback(false);
}
if (auth) {
return callback(auth);
}
else {
console.log('error');
}
});
}
const FindUser = (username,password,callback) =>{
try {
ConfigActiveDirectory.username = username;
ConfigActiveDirectory.password = password;
ad = new ActiveDirectory(ConfigActiveDirectory);
ad.findUser(username, function(err, user) {
if (err) {
console.log('ERROR: ' +JSON.stringify(err));
return;
} else{
console.log(user);
return callback(user);
}
});
} catch (error) {
return(error)
}
}
exports.ValidateLogin = ValidateLog
in; exports.FindUser = FindUser;
The function FindUser return this values:
userPrincipalName: '[email protected]',
sAMAccountName: 'deseda',
mail: '[email protected]',
whenCreated: '20200622151737.0Z',
pwdLastSet: '132445798065951322',
userAccountControl: '512',
sn: 'Deseda',
givenName: 'Carlos',
cn: 'Carlos Deseda',
displayName: 'Carlos Deseda'
But nothing about the computer, on my active directory i added the user to the computer attribute and i can see the user like this:
(Computer: ComputerDeseda) managedBy : CN=Carlos Deseda,OU=Desda,DC=deseda,DC=deseda
but i don't know how create the relation user-computer. I really appreciate any help or advice. Thank you.
Upvotes: 0
Views: 200
Reputation: 1706
When you put a user account in the "managedBy" attribute of a computer, the computer will show up in the "managedObjects" attribute for the user.
You might also check out the msDS-PrimaryComputer attribute -- that's used in group policy processing when you elect to only redirect folders on the user's primary computer (i.e. something that may already be populated for your users).
Upvotes: 1