Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enroll card for user #107

Open
JotaCoves opened this issue Dec 23, 2020 · 1 comment
Open

Enroll card for user #107

JotaCoves opened this issue Dec 23, 2020 · 1 comment

Comments

@JotaCoves
Copy link

I would like read cards for enroll it when create a user.
Anyone have some python code for this?

@core-burner
Copy link

core-burner commented Aug 19, 2024

Card reading depends on the medium of a reader and is supplied by distributor. If this is inconvenient, you can simply get the log from any device that you use to get attendance logs from. DLLs have demos named as "Card Management" inside them that can get the last read RFID from any connected device, be it TCP, RS232, or COM.
Once RFID is acquired, following function is used:

def enroll_user():
    # Create a connection to the device
    global device, user1
    zk = ZK(device.ip, device.port, force_udp=device.force_udp, ommit_ping=device.ommit_ping)
    conn = None

    try:
        # Connect to the device
        conn = zk.connect()
        conn.disable_device()
        
        # Enroll the user
        conn.set_user(uid=user1.uid, name=user1.name, privilege=user1.privilege, password=user1.password, user_id=user1.user_id, card=user1.card)

        print(f"User {user1.name} enrolled with user_id : {user1.uid}.")

    except Exception as e:
        print(f"Failed to enroll user: {e}")

    finally:
        if conn:
            conn.enable_device()
            conn.disconnect()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants