Wednesday, February 24, 2010

Novell eDirectory Group Membership with PHP

You can use the following PHP functions to manage group membership for eDirectory:

function AddUserToGroup($ldap,$userdn,$groupdn) {   
    $userInfo["groupMembership"]=$groupdn;
    $userInfo["securityEquals"]=$groupdn;
    if(ldap_mod_add($ldap,$userdn,$userInfo)===TRUE) {   
        $groupInfo["member"]=$userdn;
        $groupInfo["equivalentToMe"]=$userdn;
        return ldap_mod_add($ldap,$groupdn,$groupInfo);
    }
    return FALSE;
}

function RemoveUserFromGroup($ldap,$userdn,$groupdn) {   
    $groupInfo["member"]=$userdn;
    $groupInfo["equivalentToMe"]=$userdn;
    if(ldap_mod_del($ldap,$groupdn,$groupInfo)===TRUE) {   
        $userInfo["groupMembership"]=$groupdn;
        return ldap_mod_del($ldap,$userdn,$userInfo);
    }
    return FALSE;
}

No comments:

Followers