You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2009-01-16 11:21:03

BrainSCAN
Member
From: Spain
Registered: 2006-12-11
Posts: 86

GLPI username length > OCS user

Hello.

I have GLPI configured with LDAP authentication. I have LDAP-GLPI users with usernames with more than 20 characters.

My users have Windows installed in their PCs, and they use Windows Active Directory to authenticate in their computers. Their usernames in Windows AD has a maximum of 20 characters (Windows has this limit).

I have OCS Inventory NG, which inventories my PCs. OCS saves in the "user" field the current logged user.

I want to import OCS data into GLPI, but I don't know what will happen when GLPI tries to associate PCs with GLPI users (because for the usernames with more that 20 chars they won't match).

I still haven't tested this because it's hundreds of PCs, and I don't want to break something...

Anyone has experience with this?

Thanks.

Offline

#2 2009-01-16 11:36:04

wawa
GLPI-DEV
From: Montpellier / France
Registered: 2006-07-03
Posts: 6,019
Website

Re: GLPI username length > OCS user

Hello

If you import users from AD correctly, their login in GLPI is the samAccountName, which means the same account used to open a Windows session.
When a new computers is imported into GLPI, we get the contact field (from OCS), which means the samAccountName, and try to match it with the login field in GLPI.

It *should* work well.

Offline

#3 2009-01-16 11:44:20

BrainSCAN
Member
From: Spain
Registered: 2006-12-11
Posts: 86

Re: GLPI username length > OCS user

Hello wawa.

Thanks for the info, but my GLPI users authenticate against a LDAP server which isn't related to Active Directory.

The usernames in LDAP and in AD are the same, but in AD the usernames (samAccountName) are truncated to 20 chars long.

Offline

#4 2009-01-16 11:47:05

wawa
GLPI-DEV
From: Montpellier / France
Registered: 2006-07-03
Posts: 6,019
Website

Re: GLPI username length > OCS user

ah
then it won't work I'm afraid.
are the samAcountName and the GLPI's login the same, except that samAccountName is limited to 20 chars ?
if so, then you might be able to do automatic association by writing a plugin

Offline

#5 2009-01-16 11:56:52

BrainSCAN
Member
From: Spain
Registered: 2006-12-11
Posts: 86

Re: GLPI username length > OCS user

No, the usernames are:
GLPI username = LDAP username
OCS username = samAccountName (AD)

For example:
GLPI username = username_very_very_long
OCS username = username_very_very_

Ins't this situation already considered in GLPI?

Offline

#6 2009-01-16 12:01:21

wawa
GLPI-DEV
From: Montpellier / France
Registered: 2006-07-03
Posts: 6,019
Website

Re: GLPI username length > OCS user

no it's not currently.
the best solution might be to write a plugin to it.

Offline

#7 2009-01-16 13:35:07

BrainSCAN
Member
From: Spain
Registered: 2006-12-11
Posts: 86

Re: GLPI username length > OCS user

I have modified in ocsng.function.php the following:

if ($cfg_ocs["import_general_contact"] && !in_array("contact", $computer_updates)) {
    $compupdate["contact"] = $line["USERID"];

    $query = "SELECT ID FROM glpi_users WHERE SUBSTRING(name,1,7)='" . $line["USERID"] . "';";

//    $query = "SELECT ID FROM glpi_users WHERE name='" . $line["USERID"] . "';";
    $result = $DB->query($query);

    if ($DB->numrows($result) == 1 && !in_array("FK_users", $computer_updates)) {$compupdate["FK_users"] = $DB->result($result, 0, 0);
    }
}


And it works!.. (first I thought it didn't work, but I was making a mistake loading a different Apache)

Last edited by BrainSCAN (2009-01-20 09:40:28)

Offline

#8 2009-01-20 09:41:03

BrainSCAN
Member
From: Spain
Registered: 2006-12-11
Posts: 86

Re: GLPI username length > OCS user

Anyone knows how can I convert this into a plugin so if it is useful for someone else he can use it?

Offline

Board footer

Powered by FluxBB