def main():
    proxy_port = None
    proxy_url = None    

    securityinfo = {}
    securityinfo['security_type'] = 'Portal'#LDAP, NTLM, OAuth, Portal, PKI
    securityinfo['username'] = "******"
    securityinfo['password'] = "******"
    securityinfo['org_url'] = "http://www.arcgis.com"
    securityinfo['proxy_url'] = proxy_url
    securityinfo['proxy_port'] = proxy_port
    securityinfo['referer_url'] = None
    securityinfo['token_url'] = None
    securityinfo['certificatefile'] = None
    securityinfo['keyfile'] = None
    securityinfo['client_id'] = None
    securityinfo['secret_id'] = None   

    try:
        
        rst = resettools.resetTools(securityinfo=securityinfo)
        if rst.valid:
            users = {'users':[{'username':securityinfo['username']}]}
            
            rst.removeUserData(users=users)
            rst.removeUserGroups(users=users) 
        else:
            print rst.message
    except (common.ArcRestHelperError),e:
        print("error in function: %s" % e[0]['function'])
        print("error on line: %s" % e[0]['line'])
        print("error in file name: %s" % e[0]['filename'])
        print("with error message: %s" % e[0]['synerror'])
        if 'arcpyError' in e[0]:
            print("with arcpy message: %s" % e[0]['arcpyError'])
def main():
    proxy_port = None
    proxy_url = None

    securityinfo = {}
    securityinfo['security_type'] = 'Portal'#LDAP, NTLM, OAuth, Portal, PKI
    securityinfo['username'] = ""#Username
    securityinfo['password'] = ""#Password
    securityinfo['org_url'] = "http://www.arcgis.com"
    securityinfo['proxy_url'] = proxy_url
    securityinfo['proxy_port'] = proxy_port
    securityinfo['referer_url'] = None
    securityinfo['token_url'] = None
    securityinfo['certificatefile'] = None
    securityinfo['keyfile'] = None
    securityinfo['client_id'] = None
    securityinfo['secret_id'] = None

    try:

        rst = resettools.resetTools(securityinfo=securityinfo)
        if rst.valid:

            users = rst.securityhandler.username# comma delimited list of users  ex: 'User1, User2'

            rst.removeUserData(users=users)
            rst.removeUserGroups(users=users)
        else:
            print (rst.message)
    except (common.ArcRestHelperError) as e:
        print ("error in function: %s" % e[0]['function'])
        print ("error on line: %s" % e[0]['line'])
        print ("error in file name: %s" % e[0]['filename'])
        print ("with error message: %s" % e[0]['synerror'])
        if 'arcpyError' in e[0]:
            print ("with arcpy message: %s" % e[0]['arcpyError'])
    except:
        line, filename, synerror = trace()
        print ("error on line: %s" % line)
        print ("error in file name: %s" % filename)
        print ("with error message: %s" % synerror)
def main():
    proxy_port = None
    proxy_url = None    

    securityinfo = {}
    securityinfo['security_type'] = 'NTLM'#LDAP, NTLM, OAuth, Portal, PKI
    securityinfo['username'] = "******"#Username
    securityinfo['password'] = "******"#Password
    securityinfo['org_url'] = "https://arcrestdev2.esri.com/portal"
    securityinfo['proxy_url'] = proxy_url
    securityinfo['proxy_port'] = proxy_port
    securityinfo['referer_url'] = None
    securityinfo['token_url'] = None
    securityinfo['certificatefile'] = None
    securityinfo['keyfile'] = None
    securityinfo['client_id'] = None
    securityinfo['secret_id'] = None   

    try:
        
        rst = resettools.resetTools(securityinfo=securityinfo)
        if rst.valid:
            
            users = rst.securityhandler.username# comma delimited list of users  ex: 'User1, User2'
            
            rst.removeUserData(users=users)
            rst.removeUserGroups(users=users) 
        else:
            print rst.message
    except (common.ArcRestHelperError),e:
        print "error in function: %s" % e[0]['function']
        print "error on line: %s" % e[0]['line']
        print "error in file name: %s" % e[0]['filename']
        print "with error message: %s" % e[0]['synerror']
        if 'arcpyError' in e[0]:
            print "with arcpy message: %s" % e[0]['arcpyError']
    tbinfo = traceback.format_tb(tb)[0]
    filename = inspect.getfile(inspect.currentframe())
    # script name + line number
    line = tbinfo.split(", ")[1]
    # Get Python syntax error
    #
    synerror = traceback.format_exc().splitlines()[-1]
    return line, filename, synerror

if __name__ == "__main__":
    username = "******"
    password = "******"
    url = "<portal or AGOL url>"
    try:
        rst = resettools.resetTools(username = username, password=password,org_url=url,
                                               token_url=None, 
                                               proxy_url=None, 
                                               proxy_port=None)
        if rst.valid:
            #users = {'users':[{'username':cred_info['Username']}]}
            #arh.removeUserData(users=users)
            #arh.removeUserGroups(users=users
            arh.removeUserData()
            arh.removeUserGroups()                
    except:
        line, filename, synerror = trace()
        print("error on line: %s" % line)
        print("error in file name: %s" % filename)
        print("with error message: %s" % synerror)

    # script name + line number
    line = tbinfo.split(", ")[1]
    # Get Python syntax error
    #
    synerror = traceback.format_exc().splitlines()[-1]
    return line, filename, synerror


if __name__ == "__main__":
    username = "******"
    password = "******"
    url = "<portal or AGOL url>"
    try:
        rst = resettools.resetTools(username=username,
                                    password=password,
                                    org_url=url,
                                    token_url=None,
                                    proxy_url=None,
                                    proxy_port=None)
        if rst.valid:
            #users = {'users':[{'username':cred_info['Username']}]}
            #arh.removeUserData(users=users)
            #arh.removeUserGroups(users=users
            rst.removeUserData()
            rst.removeUserGroups()
    except:
        line, filename, synerror = trace()
        print("error on line: %s" % line)
        print("error in file name: %s" % filename)
        print("with error message: %s" % synerror)