Created
          August 18, 2025 10:45 
        
      - 
      
 - 
        
Save butonic/7e925e8091e38a8db6905b3732a3a29f to your computer and use it in GitHub Desktop.  
    migrate ownclouduuid to openclouduuid
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| LDAP_URI="ldaps://localhost:9235" | |
| BASE_DN="ou=groups,o=libregraph-idm" | |
| BIND_DN="uid=libregraph,ou=sysusers,o=libregraph-idm" | |
| LDIF_OUT="migrate-groups.ldif" | |
| # Prompt for password | |
| read -s -p "LDAP Password: " LDAP_PASS | |
| echo "" | |
| # Empty LDIF file | |
| > "$LDIF_OUT" | |
| # Search for relevant users | |
| LDAPTLS_REQCERT=never ldapsearch -x -H "$LDAP_URI" -D "$BIND_DN" -w "$LDAP_PASS" -b "$BASE_DN" \ | |
| "(owncloudUUID=*)" cn owncloudUUID objectClass | | |
| awk -v out="$LDIF_OUT" ' | |
| /^dn: / { | |
| if (dn) print_ldif() | |
| dn = $0 | |
| cn=""; uuid="" | |
| } | |
| /^cn: / { cn = $2 } | |
| /^owncloudUUID: / { uuid = $2 } | |
| END { print_ldif() } | |
| function print_ldif() { | |
| if (cn && uuid) { | |
| print dn > out | |
| print "changetype: modify" >> out | |
| print "-\nadd: openCloudUUID\nopenCloudUUID: " uuid >> out | |
| print "-\nadd: objectClass\nobjectClass: openCloudUser" >> out | |
| print "-\ndelete: owncloudUUID" >> out | |
| print "-\ndelete: objectClass\nobjectClass: ownCloudUser\n" >> out | |
| } | |
| } | |
| ' | |
| echo "LDIF generated: $LDIF_OUT" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment